結果
| 問題 | No.2028 Even Choice |
| コンテスト | |
| ユーザー |
Kiri8128
|
| 提出日時 | 2022-08-05 22:39:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 479 bytes |
| 記録 | |
| コンパイル時間 | 383 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 99,968 KB |
| 最終ジャッジ日時 | 2024-09-15 20:01:00 |
| 合計ジャッジ時間 | 4,862 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 5 |
ソースコード
from heapq import heappush, heappop
H = []
hpush = lambda x: heappush(H, x)
hpop = lambda: heappop(H)
hmin = lambda: H[0] if H else 0
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
s = 0
for i in range(N - K + 1, N):
a = A[i]
s += a
hpush(a)
ans = 0
for i in range(N - K + 1)[::-1]:
a = A[i]
if i % 2:
ans = max(ans, s + a)
m = hmin()
if a > m:
hpush(a)
hpop()
s += a - m
print(ans)
Kiri8128