結果
| 問題 | No.2028 Even Choice |
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2022-08-05 22:42:35 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 467 bytes |
| 記録 | |
| コンパイル時間 | 516 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 36,196 KB |
| 最終ジャッジ日時 | 2026-04-04 23:06:11 |
| 合計ジャッジ時間 | 7,833 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 RE * 5 |
ソースコード
from heapq import heappop, heappush
n, k = map(int, input().split())
a = list(map(int, input().split()))
hq = []
s = 0
ans = 0
for i in range(n-1, -1, -1):
if len(hq) < k-1:
heappush(hq, a[i])
s += a[i]
elif i%2 == 0:
m = heappop(hq)
heappush(hq, max(a[i], m))
s += max(a[i], m)-m
else:
ans = max(ans, a[i]+s)
m = heappop(hq)
heappush(hq, max(a[i], m))
s += max(a[i], m)-m
print(ans)
ニックネーム