結果

問題 No.2028 Even Choice
ユーザー ああいいああいい
提出日時 2022-08-07 16:36:00
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 435 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 103,892 KB
最終ジャッジ日時 2023-10-17 11:33:51
合計ジャッジ時間 7,149 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 254 ms
101,620 KB
testcase_01 AC 226 ms
101,620 KB
testcase_02 AC 260 ms
101,620 KB
testcase_03 AC 117 ms
101,696 KB
testcase_04 AC 133 ms
101,696 KB
testcase_05 AC 145 ms
80,580 KB
testcase_06 AC 249 ms
103,892 KB
testcase_07 AC 147 ms
82,608 KB
testcase_08 AC 219 ms
94,788 KB
testcase_09 AC 203 ms
98,056 KB
testcase_10 AC 94 ms
82,540 KB
testcase_11 AC 159 ms
79,916 KB
testcase_12 AC 126 ms
77,028 KB
testcase_13 AC 159 ms
101,300 KB
testcase_14 AC 169 ms
82,336 KB
testcase_15 AC 38 ms
53,364 KB
testcase_16 AC 39 ms
53,364 KB
testcase_17 AC 38 ms
53,364 KB
testcase_18 AC 41 ms
53,364 KB
testcase_19 AC 41 ms
53,364 KB
testcase_20 AC 52 ms
63,644 KB
testcase_21 AC 46 ms
61,120 KB
testcase_22 AC 45 ms
59,060 KB
testcase_23 RE -
testcase_24 AC 39 ms
53,364 KB
testcase_25 RE -
testcase_26 AC 38 ms
53,364 KB
testcase_27 AC 38 ms
53,364 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
A = list(map(int,input().split()))
import heapq
now = A[N - K + 1:N]
heapq.heapify(now)
ans = 0
nsum = sum(now)
#print(nsum)

i = N - K
for j in range(i,-1,-1):
    if j & 1:
        tmp = nsum + A[j]
        if tmp > ans:
            ans = tmp
    t = heapq.heappop(now)
    if A[j] > t:
        heapq.heappush(now,A[j])
        nsum = nsum - t + A[j]
    else:
        heapq.heappush(now,t)
print(ans)
0