結果

問題 No.1071 ベホマラー
ユーザー GrayCoderGrayCoder
提出日時 2020-06-05 22:39:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 19,268 KB
最終ジャッジ日時 2023-08-22 16:32:16
合計ジャッジ時間 3,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,892 KB
testcase_01 AC 16 ms
7,988 KB
testcase_02 AC 16 ms
7,984 KB
testcase_03 AC 16 ms
7,888 KB
testcase_04 AC 16 ms
7,836 KB
testcase_05 AC 16 ms
7,860 KB
testcase_06 AC 16 ms
7,820 KB
testcase_07 AC 16 ms
7,788 KB
testcase_08 AC 16 ms
7,800 KB
testcase_09 AC 16 ms
7,836 KB
testcase_10 AC 93 ms
17,260 KB
testcase_11 AC 91 ms
16,668 KB
testcase_12 AC 64 ms
13,812 KB
testcase_13 AC 78 ms
15,936 KB
testcase_14 AC 98 ms
17,584 KB
testcase_15 AC 108 ms
19,268 KB
testcase_16 AC 113 ms
18,920 KB
testcase_17 AC 106 ms
19,132 KB
testcase_18 AC 106 ms
19,264 KB
testcase_19 AC 108 ms
19,180 KB
testcase_20 AC 79 ms
19,000 KB
testcase_21 AC 53 ms
19,044 KB
testcase_22 AC 78 ms
18,888 KB
testcase_23 AC 54 ms
18,972 KB
testcase_24 AC 95 ms
19,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K, X, Y = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()
    hp, mp = 0, 0
    for a in A:
        a -= hp
        if a <= 1:
            N -= 1
            continue
        n = (a + K - 1) // K
        if a - (n - 1) * K <= 1:
            n -= 1
        if N * X <= Y:
            mp += n * X
            N -= 1
        else:
            hp += n * K
            mp += n * Y
            N -= 1
    print(mp)


main()
0