結果
問題 | No.2028 Even Choice |
ユーザー | ああいい |
提出日時 | 2022-08-07 16:37:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 257 ms / 2,000 ms |
コード長 | 573 bytes |
コンパイル時間 | 216 ms |
コンパイル使用メモリ | 81,644 KB |
実行使用メモリ | 103,892 KB |
最終ジャッジ日時 | 2023-10-17 11:35:21 |
合計ジャッジ時間 | 5,215 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 254 ms
101,356 KB |
testcase_01 | AC | 222 ms
101,356 KB |
testcase_02 | AC | 257 ms
101,356 KB |
testcase_03 | AC | 116 ms
101,744 KB |
testcase_04 | AC | 132 ms
101,744 KB |
testcase_05 | AC | 143 ms
80,584 KB |
testcase_06 | AC | 241 ms
103,892 KB |
testcase_07 | AC | 144 ms
82,612 KB |
testcase_08 | AC | 214 ms
94,788 KB |
testcase_09 | AC | 200 ms
98,060 KB |
testcase_10 | AC | 93 ms
82,540 KB |
testcase_11 | AC | 159 ms
79,912 KB |
testcase_12 | AC | 126 ms
77,028 KB |
testcase_13 | AC | 160 ms
101,300 KB |
testcase_14 | AC | 169 ms
82,336 KB |
testcase_15 | AC | 38 ms
53,364 KB |
testcase_16 | AC | 38 ms
53,364 KB |
testcase_17 | AC | 37 ms
53,364 KB |
testcase_18 | AC | 39 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 | AC | 38 ms
53,364 KB |
testcase_24 | AC | 37 ms
53,364 KB |
testcase_25 | AC | 39 ms
53,364 KB |
testcase_26 | AC | 38 ms
53,364 KB |
testcase_27 | AC | 39 ms
53,364 KB |
testcase_28 | AC | 70 ms
91,896 KB |
testcase_29 | AC | 60 ms
80,968 KB |
testcase_30 | AC | 54 ms
73,324 KB |
ソースコード
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) import sys if K == 1: ans = 0 for i in range(N): if i & 1 and A[i] > ans: ans = A[i] print(ans) exit() 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)