結果
| 問題 |
No.2028 Even Choice
|
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2022-06-29 21:59:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 267 ms / 2,000 ms |
| コード長 | 274 bytes |
| コンパイル時間 | 291 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 112,452 KB |
| 最終ジャッジ日時 | 2024-11-30 02:04:52 |
| 合計ジャッジ時間 | 6,540 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
とりゐ