結果
問題 | No.2028 Even Choice |
ユーザー | mkawa2 |
提出日時 | 2022-08-05 21:49:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 289 ms / 2,000 ms |
コード長 | 973 bytes |
コンパイル時間 | 1,419 ms |
コンパイル使用メモリ | 87,252 KB |
実行使用メモリ | 118,812 KB |
最終ジャッジ日時 | 2023-10-13 22:32:29 |
合計ジャッジ時間 | 6,869 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 289 ms
104,852 KB |
testcase_01 | AC | 263 ms
104,960 KB |
testcase_02 | AC | 283 ms
105,148 KB |
testcase_03 | AC | 141 ms
116,844 KB |
testcase_04 | AC | 165 ms
118,812 KB |
testcase_05 | AC | 171 ms
82,080 KB |
testcase_06 | AC | 265 ms
100,376 KB |
testcase_07 | AC | 173 ms
83,580 KB |
testcase_08 | AC | 239 ms
94,000 KB |
testcase_09 | AC | 238 ms
94,204 KB |
testcase_10 | AC | 121 ms
83,320 KB |
testcase_11 | AC | 182 ms
80,788 KB |
testcase_12 | AC | 159 ms
77,744 KB |
testcase_13 | AC | 194 ms
98,852 KB |
testcase_14 | AC | 194 ms
83,628 KB |
testcase_15 | AC | 73 ms
71,152 KB |
testcase_16 | AC | 75 ms
70,828 KB |
testcase_17 | AC | 75 ms
71,152 KB |
testcase_18 | AC | 77 ms
70,964 KB |
testcase_19 | AC | 80 ms
75,276 KB |
testcase_20 | AC | 86 ms
75,824 KB |
testcase_21 | AC | 87 ms
75,580 KB |
testcase_22 | AC | 82 ms
75,372 KB |
testcase_23 | AC | 77 ms
71,076 KB |
testcase_24 | AC | 76 ms
71,132 KB |
testcase_25 | AC | 77 ms
70,800 KB |
testcase_26 | AC | 77 ms
71,268 KB |
testcase_27 | AC | 79 ms
71,272 KB |
testcase_28 | AC | 113 ms
93,960 KB |
testcase_29 | AC | 105 ms
88,824 KB |
testcase_30 | AC | 95 ms
83,088 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = (1 << 31)-1 # md = 10**9+7 md = 998244353 from heapq import * n, k = LI() aa = LI() s = 0 hp = [] ans = 0 for i in range(n)[::-1]: a = aa[i] if i & 1 and len(hp) == k-1: ans = max(ans, a+s) s += a heappush(hp, a) if len(hp) == k: s -= heappop(hp) print(ans)