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

where is my mistake
Posted by nikipet 3 Nov 2009 03:13
#include<iostream>
using namespace std;
double a[100],s1,s2;
int n;
void read()
{
    int i;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
}
void z()
{
    int i;
    s1=a[0];
    for(i=1;i<n;i++)
    {
        if(s1<s2) s1+=a[i];
        else s2+=a[i];
    }
    if(s1<s2) cout<<s2-s1<<endl;
    else cout<<s1-s2<<endl;

}

int main ()
{
    read();
    z();
    return 0;
}

Edited by author 03.11.2009 03:34
Your Solution quite wrong.Be carefully!
Posted by QAFQAZ Sehriyar Novruzov 18 Apr 2010 15:18