結果

問題 No.2028 Even Choice
ユーザー ikomaikoma
提出日時 2022-08-05 23:30:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 86,676 KB
実行使用メモリ 118,204 KB
最終ジャッジ日時 2023-10-14 01:31:19
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 242 ms
105,168 KB
testcase_01 AC 225 ms
105,476 KB
testcase_02 AC 253 ms
105,348 KB
testcase_03 AC 138 ms
117,136 KB
testcase_04 AC 166 ms
118,204 KB
testcase_05 AC 147 ms
81,868 KB
testcase_06 AC 236 ms
100,724 KB
testcase_07 AC 154 ms
83,736 KB
testcase_08 AC 213 ms
94,560 KB
testcase_09 AC 205 ms
94,808 KB
testcase_10 AC 117 ms
83,912 KB
testcase_11 AC 147 ms
81,228 KB
testcase_12 AC 135 ms
77,780 KB
testcase_13 AC 183 ms
96,964 KB
testcase_14 AC 163 ms
83,564 KB
testcase_15 AC 76 ms
71,092 KB
testcase_16 AC 75 ms
71,188 KB
testcase_17 AC 77 ms
71,140 KB
testcase_18 AC 77 ms
71,184 KB
testcase_19 AC 81 ms
75,172 KB
testcase_20 AC 88 ms
75,704 KB
testcase_21 AC 88 ms
75,416 KB
testcase_22 AC 81 ms
75,108 KB
testcase_23 AC 74 ms
71,204 KB
testcase_24 AC 73 ms
71,136 KB
testcase_25 AC 78 ms
71,340 KB
testcase_26 AC 73 ms
71,204 KB
testcase_27 AC 74 ms
71,096 KB
testcase_28 AC 110 ms
94,264 KB
testcase_29 AC 99 ms
88,500 KB
testcase_30 AC 94 ms
83,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *
N,K=map(int,input().split())
A=list(map(int,input().split()))

hp = []
sm = 0
ans = 0
for i in range(N-1,0,-1):
    while len(hp)>=K:
        d = heappop(hp)
        sm -= d
    heappush(hp,A[i])
    sm += A[i]
    if i%2==1:
        ans = max(ans, sm)
print(ans)
0