結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー me
提出日時 2026-09-09 15:05:21
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 244 ms / 2,000 ms
+ 177µs
コード長 415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 15,232 KB
実行使用メモリ 33,196 KB
最終ジャッジ日時 2026-09-09 15:06:17
合計ジャッジ時間 5,545 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq
import sys

imput = sys.stdin.readline

n, k, x = map(int, input().split())
a = list(map(int, input().split()))

hq = []
top = 0
ans = -10 ** 18

for i in range(1, n + 1):
    t = a[i - 1]
    heapq.heappush(hq, t)
    top += t

    if len(hq) > k:
        removed = heapq.heappop(hq)
        top -= removed
    #print(hq)
    result = top - i * x
    if result > ans:
        ans = result

print(ans)
0