結果

問題 No.904 サメトロ
ユーザー ks2m
提出日時 2019-10-11 21:30:30
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 75,292 KB
実行使用メモリ 52,388 KB
最終ジャッジ日時 2024-11-25 06:47:10
合計ジャッジ時間 4,949 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int a = 0;
		int b = 0;
		for (int i = 1; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			a += Integer.parseInt(sa[0]);
			b += Integer.parseInt(sa[1]);
		}
		br.close();

		if (n == 2) {
			System.out.println(1);
		} else {
			System.out.println(Math.max(a, b) - Math.abs(a - b) + 1);
		}
	}
}
0