Quenenty's blog

By Quenenty, history, 6 years ago, In English

Hello everyone, so I'm working on tram problem (link : https://codeforces.me/contest/116/problem/A)

and while I use this code, i got 6 as the answer (a correct answer), but when i submit it to codeforces, i got 2001467757 as the output.. Can anyone help me point out why?

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string>

using namespace std;

int main() {
    int busStop, minSeat[1000], counter = 0, a[1000], b[1000];
    minSeat[0] = 0;
    cin >> busStop;
    for (int i = 0; i < busStop; i ++ )
    {
       cin >> a[i] >> b[i];
       counter = counter - a[i] + b[i];
       minSeat[i] = counter;

    }

    for (int i = 0; i < 1000; i++)
    {
       if (minSeat[0] < minSeat[i])
       {
         minSeat[0] = minSeat[i];
       }
    }
    cout << endl << minSeat[0];
}

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it