結果
| 問題 |
No.2694 The Early Bird Catches The Worm
|
| コンテスト | |
| ユーザー |
june19312
|
| 提出日時 | 2024-03-22 22:51:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 226 ms / 2,000 ms |
| コード長 | 1,025 bytes |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 82,788 KB |
| 実行使用メモリ | 149,600 KB |
| 最終ジャッジ日時 | 2024-09-30 12:16:21 |
| 合計ジャッジ時間 | 12,837 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 72 |
ソースコード
from collections import deque
N,H = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
rui = []
for i,v in enumerate(B):
if i == 0:
rui.append(v)
else:
rui.append(rui[-1]+v)
#print("rui")
#print(rui)
#print("B")
#print(B)
#print("A")
#print(A)
#print()
Q1,Q2 = deque(list(range(N))),deque()
tired = 0
manzoku = 0
ans = 0
for i,v in enumerate(B):
while Q1:
if (len(Q2)+1)*B[Q1[0]] + tired <= H:
tired += (len(Q2)+1)*B[Q1[0]]
manzoku += A[Q1[0]]
Q2.append(Q1.popleft())
else:
break
ans = max(ans,manzoku)
# print("before","Q2",Q2,"tired",tired,"manzoku",manzoku)
if len(Q2):
nex1 = Q2[0]
nex2 = Q2[-1]
tired -= rui[nex2]
if nex1 != 0:
tired += rui[nex1-1]
manzoku -= A[nex1]
Q2.popleft()
else:
Q1.popleft()
# print("after","Q2",Q2,"tired",tired,"manzoku",manzoku)
# print()
print(ans)
june19312