結果

問題 No.1071 ベホマラー
ユーザー ohanaohana
提出日時 2023-11-17 16:48:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 296 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 89,444 KB
最終ジャッジ日時 2023-11-17 16:48:14
合計ジャッジ時間 4,245 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 34 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 34 ms
53,460 KB
testcase_09 AC 35 ms
53,460 KB
testcase_10 AC 73 ms
82,660 KB
testcase_11 AC 72 ms
81,368 KB
testcase_12 AC 61 ms
74,176 KB
testcase_13 AC 83 ms
79,664 KB
testcase_14 AC 77 ms
85,112 KB
testcase_15 AC 81 ms
87,360 KB
testcase_16 AC 82 ms
87,228 KB
testcase_17 AC 81 ms
87,356 KB
testcase_18 AC 81 ms
87,344 KB
testcase_19 AC 82 ms
87,356 KB
testcase_20 AC 63 ms
86,076 KB
testcase_21 AC 65 ms
86,972 KB
testcase_22 AC 63 ms
86,076 KB
testcase_23 AC 65 ms
86,972 KB
testcase_24 AC 74 ms
89,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k, x, y = map(int, input().split())
A = list(map(int, input().split()))

th = int(-(-y // x))
B = [-(-(a - 1) // k) for a in A]
B.sort(reverse=True)

if th > n:
    print(sum(B))
else:
    Y_num = B[th - 1]
    ans = Y_num * y
    ans += sum([max(0, b - Y_num) * x for b in B])
    print(ans)
0