ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1005. Stone Pile

To admins
Posted by Hakobyan Tigran (RAU) 9 Feb 2011 01:26
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;
}
Re: To admins
Posted by xingfang 25 Feb 2011 14:00
此题的数据,有误