結果
| 問題 | No.3050 Prefix Removal |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-03-08 20:20:11 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 494 bytes |
| 記録 | |
| コンパイル時間 | 226 ms |
| コンパイル使用メモリ | 95,984 KB |
| 実行使用メモリ | 246,880 KB |
| 最終ジャッジ日時 | 2026-07-07 00:30:16 |
| 合計ジャッジ時間 | 14,400 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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