|
|
back to boardwhy "wrong answer" on test 1.???please help! Posted by holtaf 14 Nov 2010 16:07 #include<vector> //#include<string> #include<iostream> //#include<algorithm> //#include<iomanip> //#include<math.h> using namespace std; int main() { vector<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); } for(int i=0;i<n;i++) { if(w1>=w2) w2+=ivec[i]; if(w1<w2) w1+=ivec[i]; } cout<<abs(w1-w2); return 0; } |
|
|