結果
問題 |
No.2694 The Early Bird Catches The Worm
|
ユーザー |
![]() |
提出日時 | 2024-03-22 23:16:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 701 bytes |
コンパイル時間 | 417 ms |
コンパイル使用メモリ | 82,040 KB |
実行使用メモリ | 131,784 KB |
最終ジャッジ日時 | 2024-09-30 12:30:56 |
合計ジャッジ時間 | 10,483 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 61 WA * 11 |
ソースコード
N, H = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) def calc(m) -> int: a = 0 b = 0 s = 0 for i in range(m): s += B[i] * (i+1) a += A[i] b += B[i] res = 0 if s <= H: res = a for i in range(m, N): s -= b a -= A[i-m] b -= B[i-m] s += B[i] * m a += A[i] b += B[i] if s <= H: res = max(res, a) return res ans = 0 lo = 1 hi = N while lo <= hi: m = (lo + hi) // 2 res = calc(m) #print(f'{res=} {m=}') if res > 0: ans = max(ans, res) lo = m + 1 else: hi = m - 1 print(ans)