結果
| 問題 | No.2028 Even Choice |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-21 21:04:10 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 181 ms / 2,000 ms |
| コード長 | 269 bytes |
| 記録 | |
| コンパイル時間 | 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 |
ソースコード
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)