結果
| 問題 | No.2694 The Early Bird Catches The Worm |
| コンテスト | |
| ユーザー |
MM
|
| 提出日時 | 2024-09-15 16:38:25 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 515 ms / 2,000 ms |
| + 300µs | |
| コード長 | 802 bytes |
| 記録 | |
| コンパイル時間 | 382 ms |
| コンパイル使用メモリ | 14,848 KB |
| 実行使用メモリ | 60,404 KB |
| 最終ジャッジ日時 | 2026-10-16 23:08:22 |
| 合計ジャッジ時間 | 27,345 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 73 |
ソースコード
N, H = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_cumsum = [0] * (N + 1)
B_cumsum = [0] * (N + 1)
B_cumsum_weighted = [0] * (N + 1)
for i in range(1, N + 1):
A_cumsum[i] = A_cumsum[i - 1] + A[i - 1]
B_cumsum[i] = B_cumsum[i - 1] + B[i - 1]
B_cumsum_weighted[i] = B_cumsum_weighted[i - 1] + i * B[i - 1]
max_satisfaction = 0
L = 1
for R in range(1, N + 1):
while L <= R:
fatigue = (B_cumsum_weighted[R] - B_cumsum_weighted[L - 1]) - (L - 1) * (B_cumsum[R] - B_cumsum[L - 1])
if fatigue <= H:
break
L += 1
if L > R:
continue
satisfaction = A_cumsum[R] - A_cumsum[L - 1]
if satisfaction > max_satisfaction:
max_satisfaction = satisfaction
print(max_satisfaction)
MM