結果
| 問題 |
No.2028 Even Choice
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-06 00:09:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 322 bytes |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 112,256 KB |
| 最終ジャッジ日時 | 2024-09-15 22:07:31 |
| 合計ジャッジ時間 | 7,001 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 27 |
ソースコード
from heapq import heapify, heappop, heappush
n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
H = []
heapify(H)
for i in range(n - 1, -1, -1):
if i % 2 == 1 and len(H) == k - 1:
ans = max(ans, sum(H) + A[i])
heappush(H, A[i])
if len(H) == k:
heappop(H)
print(ans)