코드포스 116A (codeforces 116A)

코드포스 116A (codeforces 116A) 문제 풀이 및 코드 (description and code)

목차

Problem - 116A - Codeforces

코드

import java.io.*;

public class CF116A {
    static int n, a, b, max = 0, cur = 0;
    static String ins[];
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            ins = br.readLine().split(" ");
            a = Integer.parseInt(ins[0]);
            b = Integer.parseInt(ins[1]);
            cur -= a; cur += b;
            max = Math.max(max, cur);
        }
        bw.write(max + "\n");
        bw.flush();bw.close();
    }
}

설명