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 1190. Bar of Chocolate

Why WA test #2
Posted by Pawel 20 Jan 2011 16:40
Why I have worng anserw in test #2??

My code:

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string nazwa[5000];
    int wartosc[1000], wartosc2[1000], x, koniec = n-1, pocz = 0, min = 1, max = 10000, summin = 0, summax = 0;
    for (int i=0; i<n; i++)
    {
            cin >> nazwa[i];
            cin >> x;
            if (x == 1)
               cin >> wartosc[i];
            if (x == 0)
                wartosc[i] = 0;
            wartosc2[i] = wartosc[i];
    }

    for (int i = koniec; i>=0; i--)
    {
        if (wartosc[i] == 0)
                       wartosc[i] = min;
        else
            min = wartosc[i];
        summin += wartosc[i];
    }

    for (int i = pocz; i < n; i++)
    {
        if (wartosc2[i] == 0)
                       wartosc2[i] = max;
        else
            max = wartosc2[i];
        summax += wartosc2[i];
    }

if ( summin < 10000 && 10000 < summax)
   cout << "YES";
else
    cout << "NO";
    getchar();
    getchar();
    return 0;
    system("PAUSE");
}


Edited by author 24.01.2011 01:13