結果

問題 No.1071 ベホマラー
ユーザー RiburaRibura
提出日時 2020-06-05 22:01:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,612 KB
実行使用メモリ 17,528 KB
最終ジャッジ日時 2023-08-22 15:28:19
合計ジャッジ時間 3,783 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,836 KB
testcase_01 AC 15 ms
7,880 KB
testcase_02 AC 15 ms
7,808 KB
testcase_03 AC 15 ms
7,760 KB
testcase_04 AC 15 ms
7,840 KB
testcase_05 AC 16 ms
7,832 KB
testcase_06 AC 15 ms
7,712 KB
testcase_07 AC 15 ms
7,868 KB
testcase_08 AC 15 ms
7,792 KB
testcase_09 AC 15 ms
7,760 KB
testcase_10 AC 155 ms
15,640 KB
testcase_11 AC 182 ms
15,540 KB
testcase_12 AC 104 ms
12,972 KB
testcase_13 AC 165 ms
14,764 KB
testcase_14 AC 161 ms
16,156 KB
testcase_15 AC 226 ms
17,376 KB
testcase_16 AC 182 ms
17,292 KB
testcase_17 AC 223 ms
17,364 KB
testcase_18 AC 180 ms
17,476 KB
testcase_19 AC 178 ms
17,408 KB
testcase_20 AC 59 ms
17,464 KB
testcase_21 AC 59 ms
17,388 KB
testcase_22 AC 59 ms
17,404 KB
testcase_23 AC 57 ms
17,528 KB
testcase_24 AC 172 ms
17,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k, x, y = map(int, readline().split())
a = list(map(int, readline().split()))
a.sort()
ans = 0
now = 1
for i, aa in enumerate(a):
    if aa - now <= 0:
        continue
    m = (aa - now) // k
    ans += min(m * y, m * x * (n - i))
    now += m * k
    if (aa - now) % k != 0:
        ans += min(x * (n - i), y)
        now += k
print(ans)
0