結果
| 問題 |
No.2694 The Early Bird Catches The Worm
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-22 22:21:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 169 ms / 2,000 ms |
| コード長 | 517 bytes |
| コンパイル時間 | 268 ms |
| コンパイル使用メモリ | 82,012 KB |
| 実行使用メモリ | 145,804 KB |
| 最終ジャッジ日時 | 2024-09-30 11:52:35 |
| 合計ジャッジ時間 | 10,468 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 72 |
ソースコード
N, H = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
from itertools import accumulate
cum = list(accumulate(B, initial=0))
ans = 0
tired = 0
day = 0
r = 0
tmp = 0
for l in range(N):
while r < N and tired + (day + 1) * B[r] <= H:
tmp += A[r]
tired += (day + 1) * B[r]
day += 1
r += 1
ans = max(ans, tmp)
if l == r:
r += 1
else:
tmp -= A[l]
tired -= cum[r] - cum[l]
day -= 1
print(ans)