結果
| 問題 |
No.2028 Even Choice
|
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2022-08-05 22:03:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 367 ms / 2,000 ms |
| コード長 | 444 bytes |
| コンパイル時間 | 614 ms |
| コンパイル使用メモリ | 81,892 KB |
| 実行使用メモリ | 170,468 KB |
| 最終ジャッジ日時 | 2024-09-15 18:52:07 |
| 合計ジャッジ時間 | 6,633 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
from collections import defaultdict
import heapq
d = defaultdict(int)
sum_ = 0
q = []
for i,e in enumerate(sorted(set(a))):
d[e] = i + 1
for i in range(n-1,0,-1):
if i & 1:
ans = max(ans ,a[i] + sum_)
heapq.heappush(q,a[i])
else:
heapq.heappush(q,a[i])
sum_ += a[i]
if len(q) > k-1:
sum_ -= heapq.heappop(q)
print(ans)
SidewaysOwl