結果

問題 No.2028 Even Choice
コンテスト
ユーザー ああ
提出日時 2026-05-21 21:04:10
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 269 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 311 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 125,824 KB
最終ジャッジ日時 2026-05-21 21:04:22
合計ジャッジ時間 6,157 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq

n,k=map(int,input().split())
a=list(map(int,input().split()));hq=[];c=0;ans=0
for i in range(n-1,-1,-1):
    if len(hq)>=k-1 and i&1:
       ans=max(ans,a[i]+c)
    heapq.heappush(hq,a[i]);c+=a[i]
    if len(hq)==k:
        c-=heapq.heappop(hq)
print(ans)
0