結果
| 問題 | No.2028 Even Choice |
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2022-06-29 21:59:36 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 2,000 ms |
| コード長 | 274 bytes |
| 記録 | |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 85,448 KB |
| 実行使用メモリ | 113,920 KB |
| 最終ジャッジ日時 | 2026-05-23 19:02:48 |
| 合計ジャッジ時間 | 7,448 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
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)
とりゐ