Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
multiset慢姿势#include<stdio.h> #include <iomanip> #include<iostream> #include<math.h> #include<algorithm> #define eps 1e-8 #define zero(x) (((x)>0?(x):-(x))<eps) #include<set> #define pi acos(-1.0) using namespace std; multiset<__int64>Set; multiset<__int64>::iterator it; int main() { int n; scanf("%d",&n); Set.clear(); __int64 t; for(int i=0;i<n;i++) { scanf("%I64d",&t); Set.insert(t); } __int64 sum=0; while(Set.size()!=1) { __int64 t1,t2,t3; it=Set.begin(); t1=*it;sum+=t1; Set.erase(it); it=Set.begin(); t2=*it;sum+=t2; Set.erase(it); t3=t1+t2; Set.insert(t3); } printf("%I64d\n",sum); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator