結果

問題 No.1160 Strange Bowling
ユーザー brthyyjp
提出日時 2021-07-05 22:04:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 343 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 82,768 KB
実行使用メモリ 81,252 KB
最終ジャッジ日時 2024-07-01 12:02:40
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
PA = []
for i in range(n):
    p, a = map(int, input().split())
    PA.append((p, a))
PA.reverse()

ans = 0
for i in range(n):
    p, a = PA[i]
    if i == 0:
        ans += p
        x = p
    else:
        if x+a >= p:
            ans += x+a
            x = a
        else:
            ans += p
            x = p
print(ans)
0