結果
問題 |
No.3050 Prefix Removal
|
ユーザー |
![]() |
提出日時 | 2025-03-08 20:21:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 415 ms / 2,000 ms |
コード長 | 522 bytes |
コンパイル時間 | 410 ms |
コンパイル使用メモリ | 82,168 KB |
実行使用メモリ | 208,304 KB |
最終ジャッジ日時 | 2025-03-08 20:21:56 |
合計ジャッジ時間 | 16,569 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 55 |
ソースコード
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**20) 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]) SUM += cum[i-1] ans = max(ans, cum[i]*K-SUM) print(ans)