|  | 
|  | 
| back to board | now on test 5 wa Posted by holtaf  14 Nov 2010 16:41#include<vector>//#include<string>
 #include<iostream>
 #include<algorithm>
 
 //#include<iomanip>
 //#include<math.h>
 using namespace std;
 int main()
 {
 vector<long int>ivec;
 int n,p;
 cin>>n;
 int w1=0,w2=0;
 for(int u=0;u<n;u++)
 {cin>>p;
 ivec.push_back(p);
 }
 sort(&ivec[0],&ivec[n]);
 for(int i=n-1;i>=0;i--)
 {
 if(w1>w2)
 {w2+=ivec[i];
 continue;
 }
 if(w1<w2)
 {w1+=ivec[i];
 continue;
 }
 if(w1==w2)
 {w1+=ivec[i];
 continue;
 }}
 cout<<abs(w1-w2);
 
 return 0;
 
 }
 | 
 | 
|