結果
問題 | No.633 バスの運賃 |
ユーザー |
![]() |
提出日時 | 2020-02-05 07:32:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 679 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 60,160 KB |
最終ジャッジ日時 | 2024-09-21 23:44:06 |
合計ジャッジ時間 | 1,561 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 |
ソースコード
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: 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()