結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー ゆき
提出日時 2026-08-30 15:30:13
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,168 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 240 ms
コンパイル使用メモリ 95,852 KB
実行使用メモリ 118,024 KB
最終ジャッジ日時 2026-08-30 15:30:17
合計ジャッジ時間 4,633 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other TLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
sys.setrecursionlimit(2000)
input = sys.stdin.readline
#無限大
#INF = (1 << 61) - 1
#4つのマスチェック用
four_step = [(0, 1), (1, 0), (-1, 0), (0, -1)]
def chmmin(a, b):
    if a > b:
        a = b
        return True
    else:
        return False
def chmax(a, b):
    if a < b:
        a = b
        return True
    else:
        return False
N, K, X = map(int, input().split())
array_A = list(map(int, input().split()))
import heapq
heap = []
do_count = 0
len_array_A = 0
last_ans = -1 * 10**10
array_tmp = []
tmp_count = 0
for i in range(N):
    heapq.heappush(heap, -array_A[i])
    array_tmp = []
    tmp_count = 0
    len_array_A += 1
    ans = 0
    do_count = min(K, i+1)
    #print("do_count", do_count)
    for j in range(do_count):
        if j < len_array_A:
            tmp = heapq.heappop(heap)
            ans -= tmp
            array_tmp.append(tmp)
            tmp_count += 1
            #print("ans", ans)
        else: 
            break
    #print("ans", ans)
    ans -= X*(i+1)
    for j in range(tmp_count):
        heapq.heappush(heap, -array_tmp[j])
    #print(ans)
    last_ans = max(ans, last_ans)
print(last_ans)
    
0