結果

問題 No.2028 Even Choice
ユーザー titiatitia
提出日時 2022-08-05 23:20:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 353 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,556 KB
実行使用メモリ 30,200 KB
最終ジャッジ日時 2023-10-14 01:12:29
合計ジャッジ時間 5,609 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 349 ms
30,044 KB
testcase_01 AC 293 ms
30,048 KB
testcase_02 AC 373 ms
30,200 KB
testcase_03 AC 206 ms
30,048 KB
testcase_04 AC 228 ms
30,068 KB
testcase_05 AC 72 ms
12,668 KB
testcase_06 AC 327 ms
28,008 KB
testcase_07 AC 82 ms
13,880 KB
testcase_08 AC 248 ms
21,552 KB
testcase_09 AC 225 ms
24,000 KB
testcase_10 AC 67 ms
13,804 KB
testcase_11 AC 77 ms
11,888 KB
testcase_12 AC 43 ms
9,692 KB
testcase_13 AC 171 ms
25,496 KB
testcase_14 AC 114 ms
14,136 KB
testcase_15 AC 17 ms
8,080 KB
testcase_16 AC 16 ms
7,984 KB
testcase_17 AC 17 ms
8,056 KB
testcase_18 AC 17 ms
8,008 KB
testcase_19 AC 17 ms
7,900 KB
testcase_20 AC 18 ms
8,004 KB
testcase_21 AC 17 ms
8,016 KB
testcase_22 AC 18 ms
7,948 KB
testcase_23 AC 16 ms
8,020 KB
testcase_24 AC 17 ms
7,968 KB
testcase_25 AC 16 ms
7,980 KB
testcase_26 AC 16 ms
8,072 KB
testcase_27 AC 16 ms
8,012 KB
testcase_28 AC 192 ms
22,172 KB
testcase_29 AC 127 ms
17,440 KB
testcase_30 AC 91 ms
14,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import heappop,heappush

N,K=map(int,input().split())
A=list(map(int,input().split()))

H=[]
SUM=0
ANS=0

for i in range(N-1,0,-1):
    if i%2==1 and len(H)==K-1:
        ANS=max(ANS,SUM+A[i])

    heappush(H,A[i])
    SUM+=A[i]
    while len(H)>K-1:
        x=heappop(H)
        SUM-=x

print(ANS)
    
0