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 1515. Cashmaster

COOL Solution
Posted by Mihran Hovsepyan {2 kurs of <RAU>} 17 Oct 2008 22:15
# include <iostream>
using namespace std;
main()
{
    int n,b[100];
    int i,max=0;
    cin>>n;
    for(i=0;i<n;i++) cin>>b[i];
    for(i=0;i<n;i++)
    {
        if(b[i]>max+1)
        {cout<<max+1;return 0;}
        else
            max+=b[i];
    }
    cout<<max+1;
    return 0;
}

Edited by author 22.10.2008 22:13
Re: COOL Solution
Posted by Grigor Gevorgian 18 Oct 2008 16:52
Hey,pal,why do you sort the array? It is already sorted!