結果

問題 No.633 バスの運賃
ユーザー tails1434tails1434
提出日時 2020-02-05 07:32:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 81,404 KB
実行使用メモリ 61,260 KB
最終ジャッジ日時 2023-10-21 22:08:21
合計ジャッジ時間 1,458 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,480 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 40 ms
55,480 KB
testcase_06 AC 38 ms
53,432 KB
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
from collections import defaultdict

def main():
    n = int(input())
    a = [0] + [int(input()) for _ in range(n - 1)]
    sum_a = list(accumulate(a))
    d = defaultdict(int)
    ans = 0
    for i in range(n):
        b, c = map(int, input().split())
        for j, k in d.items():
            tmp = sum_a[i] - sum_a[j]
            if k == 0:
                continue
            if b > k:
                print(tmp * k)
                ans += tmp * k
                d[j] = 0
                b -= k
            else:
                ans += tmp * b
                d[j] -= b
                break
        d[i] += c

    print(ans)






if __name__ == "__main__":
    main()
0