結果
| 問題 |
No.3050 Prefix Removal
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-03-08 20:20:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 494 bytes |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 82,400 KB |
| 実行使用メモリ | 208,824 KB |
| 最終ジャッジ日時 | 2025-03-08 20:20:29 |
| 合計ジャッジ時間 | 16,837 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 47 |
ソースコード
from heapq import heappush, heappop
N, K = map(int, input().split())
A = list(map(int, input().split()))
cum = [0]
for a in A:
cum.append(cum[-1]+a)
cum.pop(0)
que = []
SUM = 0
ans = -(10**18)
for i in range(K-1, N):
if i == K-1:
for j in range(K-1):
heappush(que, -cum[j])
SUM += cum[j]
else:
if que and cum[i-1] < -que[0]:
SUM -= -heappop(que)
heappush(que, -cum[i-1])
ans = max(ans, cum[i]*K-SUM)
print(ans)
detteiuu