結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー Kohei
提出日時 2026-09-02 22:22:59
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 162 ms / 2,000 ms
+ 630µs
コード長 342 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 225 ms
コンパイル使用メモリ 96,072 KB
実行使用メモリ 117,096 KB
最終ジャッジ日時 2026-09-02 22:23:05
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from heapq import heappush, heappop
N, K, X = map(int, input().split())
A = list(map(int, input().split()))

L = []
total = 0
ans = -1e18
for i in range(N):
    a = A[i]
    heappush(L, a)
    total += a
    if i >= K:
        rm = heappop(L)
        total -= rm
    memo = total - (i + 1)*X
    if memo > ans:
        ans = memo

print(ans)
0