結果
問題 |
No.2028 Even Choice
|
ユーザー |
![]() |
提出日時 | 2022-08-05 23:20:50 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 447 ms / 2,000 ms |
コード長 | 353 bytes |
コンパイル時間 | 91 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 32,708 KB |
最終ジャッジ日時 | 2024-09-15 20:56:51 |
合計ジャッジ時間 | 6,222 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import sys input = sys.stdin.readline from heapq import heappop,heappush N,K=map(int,input().split()) A=list(map(int,input().split())) H=[] SUM=0 ANS=0 for i in range(N-1,0,-1): if i%2==1 and len(H)==K-1: ANS=max(ANS,SUM+A[i]) heappush(H,A[i]) SUM+=A[i] while len(H)>K-1: x=heappop(H) SUM-=x print(ANS)