結果

問題 No.904 サメトロ
ユーザー ks2mks2m
提出日時 2019-10-11 21:47:30
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 981 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 76,252 KB
実行使用メモリ 38,368 KB
最終ジャッジ日時 2024-05-04 01:23:41
合計ジャッジ時間 7,110 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
38,268 KB
testcase_01 AC 46 ms
36,960 KB
testcase_02 AC 130 ms
38,244 KB
testcase_03 AC 58 ms
37,316 KB
testcase_04 AC 128 ms
38,088 KB
testcase_05 AC 47 ms
36,940 KB
testcase_06 AC 175 ms
38,216 KB
testcase_07 AC 56 ms
37,268 KB
testcase_08 AC 357 ms
37,944 KB
testcase_09 AC 46 ms
36,912 KB
testcase_10 AC 75 ms
38,196 KB
testcase_11 AC 75 ms
38,036 KB
testcase_12 AC 50 ms
37,040 KB
testcase_13 AC 50 ms
36,644 KB
testcase_14 AC 54 ms
36,804 KB
testcase_15 AC 50 ms
36,932 KB
testcase_16 AC 82 ms
38,184 KB
testcase_17 AC 47 ms
36,692 KB
testcase_18 AC 48 ms
36,684 KB
testcase_19 AC 53 ms
36,964 KB
testcase_20 AC 46 ms
36,556 KB
testcase_21 AC 71 ms
37,424 KB
testcase_22 AC 228 ms
37,948 KB
testcase_23 AC 74 ms
38,208 KB
testcase_24 AC 104 ms
38,112 KB
testcase_25 AC 46 ms
36,956 KB
testcase_26 AC 74 ms
38,280 KB
testcase_27 TLE -
testcase_28 AC 47 ms
37,152 KB
testcase_29 AC 49 ms
37,016 KB
testcase_30 AC 48 ms
36,900 KB
testcase_31 AC 46 ms
37,092 KB
testcase_32 AC 45 ms
36,940 KB
testcase_33 AC 47 ms
37,172 KB
testcase_34 AC 46 ms
36,928 KB
testcase_35 AC 54 ms
36,896 KB
権限があれば一括ダウンロードができます

ソースコード

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 = new int[n];
		int[] b = new int[n];
		int xa = 0;
		int xb = 0;
		for (int i = 1; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]);
			b[i] = Integer.parseInt(sa[1]);
			xa += a[i];
			xb += b[i];
		}
		br.close();

		a[0] = xb;
		b[0] = xa;

		int ans = 0;
		while (a[0] >= 0 && b[0] >= 0) {
			boolean flg = true;
			for (int i = 0; i < n; i++) {
				xa = 0;
				xb = 0;
				for (int j = 0; j < n; j++) {
					if (i != j) {
						xa += a[j];
						xb += b[j];
					}
				}
				if (xa < b[i] || xb < a[i]) {
					flg = false;
					break;
				}
			}
			if (flg) {
				ans++;
				a[0]--;
				b[0]--;
			} else {
				break;
			}
		}
		System.out.println(ans);
	}
}
0