結果

問題 No.1071 ベホマラー
ユーザー neterukunneterukun
提出日時 2020-06-05 21:31:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 86,656 KB
最終ジャッジ日時 2024-05-09 20:08:16
合計ジャッジ時間 2,400 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
51,840 KB
testcase_01 AC 32 ms
51,840 KB
testcase_02 AC 32 ms
51,968 KB
testcase_03 AC 31 ms
52,196 KB
testcase_04 AC 32 ms
51,712 KB
testcase_05 AC 31 ms
51,712 KB
testcase_06 AC 32 ms
52,096 KB
testcase_07 AC 32 ms
51,696 KB
testcase_08 AC 32 ms
51,712 KB
testcase_09 AC 35 ms
51,968 KB
testcase_10 AC 76 ms
81,536 KB
testcase_11 AC 74 ms
80,384 KB
testcase_12 AC 60 ms
73,344 KB
testcase_13 AC 67 ms
78,976 KB
testcase_14 AC 73 ms
82,944 KB
testcase_15 AC 77 ms
85,248 KB
testcase_16 AC 77 ms
85,248 KB
testcase_17 AC 80 ms
86,656 KB
testcase_18 AC 77 ms
86,656 KB
testcase_19 AC 78 ms
86,272 KB
testcase_20 AC 63 ms
85,032 KB
testcase_21 AC 62 ms
84,992 KB
testcase_22 AC 65 ms
85,120 KB
testcase_23 AC 64 ms
84,736 KB
testcase_24 AC 72 ms
86,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for i in range(n):
    a[i] -= 1

# 残りがcnt人以上ならベホマラーがお得
cnt = -((-y) // x)
a = sorted(a)
ind = n - cnt
if ind < 0:
    cnt_y = 0
    ans = 0
else:
    cnt_y = -((-a[ind]) // k)
    ans = cnt_y * y

for i in range(n):
    a[i] -= cnt_y * k
    if a[i] > 0:
        ans += -((-a[i]) // k) * x
print(ans)
0