結果

問題 No.2028 Even Choice
ユーザー 👑 tamatotamato
提出日時 2022-08-05 21:29:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 118,196 KB
最終ジャッジ日時 2023-10-13 21:58:24
合計ジャッジ時間 6,355 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 247 ms
104,860 KB
testcase_01 AC 244 ms
105,184 KB
testcase_02 AC 264 ms
105,376 KB
testcase_03 AC 138 ms
116,828 KB
testcase_04 AC 158 ms
118,196 KB
testcase_05 AC 160 ms
82,344 KB
testcase_06 AC 254 ms
100,728 KB
testcase_07 AC 160 ms
83,976 KB
testcase_08 AC 232 ms
94,716 KB
testcase_09 AC 217 ms
94,556 KB
testcase_10 AC 115 ms
83,972 KB
testcase_11 AC 166 ms
81,192 KB
testcase_12 AC 151 ms
78,388 KB
testcase_13 AC 175 ms
96,864 KB
testcase_14 AC 179 ms
83,880 KB
testcase_15 AC 71 ms
71,456 KB
testcase_16 AC 70 ms
71,508 KB
testcase_17 AC 70 ms
71,356 KB
testcase_18 AC 73 ms
71,420 KB
testcase_19 AC 74 ms
75,016 KB
testcase_20 AC 81 ms
75,900 KB
testcase_21 AC 80 ms
75,800 KB
testcase_22 AC 77 ms
75,400 KB
testcase_23 AC 74 ms
71,052 KB
testcase_24 AC 73 ms
71,432 KB
testcase_25 AC 72 ms
71,436 KB
testcase_26 AC 73 ms
71,492 KB
testcase_27 AC 73 ms
71,232 KB
testcase_28 AC 109 ms
94,388 KB
testcase_29 AC 98 ms
88,616 KB
testcase_30 AC 92 ms
83,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    from heapq import heappop, heappush
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    S = 0
    pq = []
    ans = 0
    for i in range(N - 1, -1, -1):
        a = A[i]
        if i & 1:
            ans = max(ans, a + S)

        heappush(pq, a)
        S += a
        if len(pq) >= K:
            t = heappop(pq)
            S -= t
    print(ans)


if __name__ == '__main__':
    main()
0