|  | 
|  | 
| back to board | To admins Why this solution got AC ? For the first test it outputs 15, but correct answer is 3 !!!!#include <iostream>
 #include <complex>
 #include <algorithm>
 #include <cmath>
 #include <vector>
 #include <string>
 using namespace std;
 int main()
 {
 int n,i,total=0,counter;
 int l;
 vector <int> x;
 cin>>n;
 for(i=0; i<n; i++)
 {
 cin>>l;
 x.push_back(l);
 }
 for(i=0; i<n; i++)
 {
 total+=x[i];
 }
 counter=total/2;
 for(i=0; i<n; i++)
 {
 if(x[i]<=counter)
 {
 counter-=x[i];
 }
 }
 cout<<2*counter+total%2;
 return 0;
 }
 | 
 | 
|