結果

問題 No.904 サメトロ
ユーザー roarisroaris
提出日時 2020-12-10 12:29:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 1,000 ms
コード長 389 bytes
コンパイル時間 1,349 ms
コンパイル使用メモリ 81,540 KB
実行使用メモリ 75,028 KB
最終ジャッジ日時 2023-10-20 00:20:20
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
61,804 KB
testcase_01 AC 44 ms
61,964 KB
testcase_02 AC 54 ms
61,804 KB
testcase_03 AC 50 ms
61,960 KB
testcase_04 AC 44 ms
61,820 KB
testcase_05 AC 35 ms
53,464 KB
testcase_06 AC 49 ms
63,868 KB
testcase_07 AC 48 ms
62,032 KB
testcase_08 AC 54 ms
65,916 KB
testcase_09 AC 35 ms
53,464 KB
testcase_10 AC 44 ms
61,960 KB
testcase_11 AC 44 ms
61,960 KB
testcase_12 AC 38 ms
59,432 KB
testcase_13 AC 45 ms
62,032 KB
testcase_14 AC 43 ms
59,780 KB
testcase_15 AC 39 ms
59,432 KB
testcase_16 AC 47 ms
62,056 KB
testcase_17 AC 36 ms
53,464 KB
testcase_18 AC 36 ms
53,464 KB
testcase_19 AC 44 ms
62,032 KB
testcase_20 AC 35 ms
53,464 KB
testcase_21 AC 51 ms
62,044 KB
testcase_22 AC 49 ms
63,852 KB
testcase_23 AC 44 ms
61,960 KB
testcase_24 AC 49 ms
61,804 KB
testcase_25 AC 35 ms
53,464 KB
testcase_26 AC 45 ms
61,976 KB
testcase_27 AC 83 ms
75,028 KB
testcase_28 AC 35 ms
53,464 KB
testcase_29 AC 35 ms
53,464 KB
testcase_30 AC 35 ms
53,464 KB
testcase_31 AC 36 ms
53,464 KB
testcase_32 AC 35 ms
53,464 KB
testcase_33 AC 35 ms
53,464 KB
testcase_34 AC 35 ms
53,464 KB
testcase_35 AC 43 ms
59,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A, B = [], []

for _ in range(N-1):
    Ai, Bi = map(int, input().split())
    A.append(Ai)
    B.append(Bi)

ans = 0
SA, SB = sum(A), sum(B)

for A1 in range(SB+1):
    B1 = SA+A1-SB
    
    if B1<0:
        continue
    
    for i in range(N-1):
        if A[i]>B1+SB-B[i]:
            break
    else:
        ans += 1

print(ans)
0