Tuesday, March 18, 2014

Codeforces Beta Round #87 (Div. 2 Only), problem: (A) Tram solution

Codeforces Beta Round #87 (Div. 2 Only), problem: (A) Tram: http://codeforces.com/problemset/problem/116/A

Codeforces Beta Round #87 (Div. 2 Only), problem: (A) Tram solution: http://ideone.com/w9XSS5

#include <iostream>
#include <cstdio>
#include <climits>
using namespace std;

int main() {
    int n, a, b, sum, max;
    sum=0;
    max=INT_MIN;
    scanf("%d", &n);
    while(n--) {
        scanf("%d%d", &a, &b);
        sum=sum-a+b;
        if(sum>max) max=sum;
    }
    printf("%d", max);
    return 0;
}

No comments:

Post a Comment