結果

問題 No.2028 Even Choice
ユーザー first_vilfirst_vil
提出日時 2022-08-05 21:30:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 119,012 KB
最終ジャッジ日時 2023-10-13 22:00:55
合計ジャッジ時間 6,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
105,804 KB
testcase_01 AC 241 ms
106,144 KB
testcase_02 AC 270 ms
106,132 KB
testcase_03 AC 142 ms
117,152 KB
testcase_04 AC 170 ms
119,012 KB
testcase_05 AC 158 ms
82,504 KB
testcase_06 AC 250 ms
100,416 KB
testcase_07 AC 162 ms
84,412 KB
testcase_08 AC 227 ms
95,416 KB
testcase_09 AC 219 ms
94,820 KB
testcase_10 AC 124 ms
84,332 KB
testcase_11 AC 165 ms
81,412 KB
testcase_12 AC 148 ms
78,720 KB
testcase_13 AC 188 ms
96,728 KB
testcase_14 AC 180 ms
84,064 KB
testcase_15 AC 73 ms
71,240 KB
testcase_16 AC 73 ms
71,308 KB
testcase_17 AC 74 ms
71,468 KB
testcase_18 AC 77 ms
71,188 KB
testcase_19 AC 79 ms
75,408 KB
testcase_20 AC 86 ms
75,860 KB
testcase_21 AC 83 ms
75,628 KB
testcase_22 AC 80 ms
75,580 KB
testcase_23 AC 75 ms
71,308 KB
testcase_24 AC 75 ms
71,408 KB
testcase_25 AC 75 ms
71,568 KB
testcase_26 AC 74 ms
71,468 KB
testcase_27 AC 74 ms
71,484 KB
testcase_28 AC 116 ms
95,864 KB
testcase_29 AC 105 ms
89,972 KB
testcase_30 AC 98 ms
83,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush
import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353

n, k = mi()
a = li()
q = []
heapify(q)
ans = 0
s = 0
for i in range(n)[::-1]:
    if i & 1:
        ans = max(ans, s + a[i])
    heappush(q, a[i])
    s += a[i]
    while len(q) >= k:
        s -= heappop(q)
print(ans)
0