結果

問題 No.2028 Even Choice
ユーザー とりゐとりゐ
提出日時 2022-06-29 21:59:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 112,644 KB
最終ジャッジ日時 2024-05-07 10:18:33
合計ジャッジ時間 5,394 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 233 ms
102,084 KB
testcase_01 AC 216 ms
102,144 KB
testcase_02 AC 242 ms
101,848 KB
testcase_03 AC 109 ms
112,644 KB
testcase_04 AC 134 ms
111,852 KB
testcase_05 AC 132 ms
80,852 KB
testcase_06 AC 221 ms
103,968 KB
testcase_07 AC 136 ms
83,460 KB
testcase_08 AC 201 ms
95,608 KB
testcase_09 AC 195 ms
98,416 KB
testcase_10 AC 87 ms
82,880 KB
testcase_11 AC 144 ms
80,520 KB
testcase_12 AC 123 ms
77,524 KB
testcase_13 AC 156 ms
101,408 KB
testcase_14 AC 159 ms
82,972 KB
testcase_15 AC 37 ms
53,624 KB
testcase_16 AC 38 ms
53,196 KB
testcase_17 AC 38 ms
52,764 KB
testcase_18 AC 42 ms
54,208 KB
testcase_19 AC 43 ms
59,892 KB
testcase_20 AC 50 ms
62,488 KB
testcase_21 AC 49 ms
62,028 KB
testcase_22 AC 45 ms
59,308 KB
testcase_23 AC 38 ms
53,076 KB
testcase_24 AC 38 ms
53,356 KB
testcase_25 AC 38 ms
53,220 KB
testcase_26 AC 38 ms
54,604 KB
testcase_27 AC 38 ms
52,660 KB
testcase_28 AC 76 ms
93,284 KB
testcase_29 AC 67 ms
84,880 KB
testcase_30 AC 61 ms
77,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop,heappush

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

mx=0
hq=[]

sm=0
for i in range(n-1,-1,-1):
  if i%2==1 and len(hq)==k-1:
    mx=max(mx,sm+a[i])
  sm+=a[i]
  heappush(hq,a[i])
  if len(hq)>=k:
    sm-=heappop(hq)

print(mx)
0