結果

問題 No.1071 ベホマラー
ユーザー yuly3yuly3
提出日時 2020-06-26 10:39:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 92,088 KB
最終ジャッジ日時 2023-09-16 23:34:40
合計ジャッジ時間 4,323 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,164 KB
testcase_01 AC 65 ms
71,112 KB
testcase_02 AC 71 ms
71,368 KB
testcase_03 AC 65 ms
71,328 KB
testcase_04 AC 66 ms
71,412 KB
testcase_05 AC 67 ms
71,360 KB
testcase_06 AC 65 ms
71,244 KB
testcase_07 AC 65 ms
71,100 KB
testcase_08 AC 65 ms
71,164 KB
testcase_09 AC 66 ms
71,160 KB
testcase_10 AC 100 ms
88,900 KB
testcase_11 AC 96 ms
87,540 KB
testcase_12 AC 88 ms
83,064 KB
testcase_13 AC 95 ms
86,428 KB
testcase_14 AC 101 ms
89,328 KB
testcase_15 AC 104 ms
91,528 KB
testcase_16 AC 108 ms
91,132 KB
testcase_17 AC 105 ms
91,920 KB
testcase_18 AC 108 ms
92,088 KB
testcase_19 AC 104 ms
91,568 KB
testcase_20 AC 91 ms
91,832 KB
testcase_21 AC 88 ms
91,172 KB
testcase_22 AC 92 ms
91,612 KB
testcase_23 AC 93 ms
91,684 KB
testcase_24 AC 97 ms
91,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K, X, Y = map(int, rl().split())
    A = [ai - 1 for ai in map(int, rl().split())]
    
    lim = Y // X
    if lim == 0:
        print(-(-max(A) // K))
        return
    
    B = [-(-ai // K) for ai in A]
    B.sort()
    C = B[-lim:]
    
    cnt = 0
    if len(C) != N:
        cnt = B[-(lim + 1)]
    
    ans = cnt * Y
    for ci in C:
        ans += (ci - cnt) * X
    print(ans)


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