結果
問題 | No.2028 Even Choice |
ユーザー |
![]() |
提出日時 | 2022-08-05 21:49:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 240 ms / 2,000 ms |
コード長 | 375 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 112,768 KB |
最終ジャッジ日時 | 2024-09-15 18:16:20 |
合計ジャッジ時間 | 5,218 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import heapqN,K = map(int, input().split())A = list(map(int, input().split()))H = []heapSum = 0ans = 0for i in reversed(range(N)):if len(H)<K-1:heapq.heappush(H,A[i])heapSum+=A[i]else:if i%2==1:ans = max(ans,A[i]+heapSum)heapSum+=A[i]heapq.heappush(H,A[i])heapSum-=heapq.heappop(H)print(ans)