結果

問題 No.904 サメトロ
ユーザー AT274_AT274_
提出日時 2019-10-11 22:56:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 1,000 ms
コード長 428 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 67,936 KB
最終ジャッジ日時 2024-05-04 02:45:33
合計ジャッジ時間 2,568 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
59,520 KB
testcase_01 AC 43 ms
59,648 KB
testcase_02 AC 59 ms
61,440 KB
testcase_03 AC 41 ms
60,288 KB
testcase_04 AC 45 ms
60,672 KB
testcase_05 AC 36 ms
52,096 KB
testcase_06 AC 52 ms
61,056 KB
testcase_07 AC 40 ms
59,520 KB
testcase_08 AC 61 ms
61,884 KB
testcase_09 AC 33 ms
51,940 KB
testcase_10 AC 40 ms
60,184 KB
testcase_11 AC 39 ms
60,512 KB
testcase_12 AC 36 ms
57,964 KB
testcase_13 AC 41 ms
60,056 KB
testcase_14 AC 40 ms
61,236 KB
testcase_15 AC 34 ms
59,324 KB
testcase_16 AC 38 ms
59,548 KB
testcase_17 AC 32 ms
53,104 KB
testcase_18 AC 32 ms
52,692 KB
testcase_19 AC 39 ms
60,712 KB
testcase_20 AC 31 ms
52,772 KB
testcase_21 AC 37 ms
59,824 KB
testcase_22 AC 56 ms
62,876 KB
testcase_23 AC 38 ms
60,836 KB
testcase_24 AC 48 ms
61,740 KB
testcase_25 AC 32 ms
52,396 KB
testcase_26 AC 39 ms
59,468 KB
testcase_27 AC 96 ms
67,936 KB
testcase_28 AC 33 ms
52,892 KB
testcase_29 AC 33 ms
52,740 KB
testcase_30 AC 34 ms
53,176 KB
testcase_31 AC 32 ms
52,200 KB
testcase_32 AC 32 ms
52,424 KB
testcase_33 AC 31 ms
52,988 KB
testcase_34 AC 31 ms
53,168 KB
testcase_35 AC 38 ms
59,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A_sum, B_sum = 0, 0
X = []
for i in range(N - 1):
    A, B = map(int,input().split())
    X.append([A, B])
    A_sum += A
    B_sum += B


ans = 0
for nb in range(A_sum, -1, -1):
    na = B_sum + nb - A_sum
    if na < 0 or nb < 0:
        continue
    for a, b in X:
        if (B_sum + nb - b) < a:
            break

        if (A_sum + na - a) < b:
            break
    else:
        ans += 1


print(ans)
0