結果

問題 No.1071 ベホマラー
ユーザー anagohirameanagohirame
提出日時 2020-06-05 21:33:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 337 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 29,020 KB
最終ジャッジ日時 2023-08-22 14:28:19
合計ジャッジ時間 5,093 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,640 KB
testcase_01 AC 18 ms
8,468 KB
testcase_02 AC 18 ms
8,528 KB
testcase_03 AC 17 ms
8,532 KB
testcase_04 AC 18 ms
8,640 KB
testcase_05 AC 18 ms
8,664 KB
testcase_06 AC 17 ms
8,644 KB
testcase_07 AC 18 ms
8,636 KB
testcase_08 AC 18 ms
8,532 KB
testcase_09 AC 18 ms
8,496 KB
testcase_10 AC 271 ms
23,740 KB
testcase_11 AC 266 ms
23,372 KB
testcase_12 AC 175 ms
19,068 KB
testcase_13 AC 230 ms
21,940 KB
testcase_14 AC 289 ms
24,316 KB
testcase_15 AC 336 ms
29,020 KB
testcase_16 AC 329 ms
28,824 KB
testcase_17 AC 331 ms
28,852 KB
testcase_18 AC 330 ms
28,832 KB
testcase_19 AC 337 ms
28,948 KB
testcase_20 AC 115 ms
19,192 KB
testcase_21 AC 115 ms
19,264 KB
testcase_22 AC 115 ms
19,364 KB
testcase_23 AC 114 ms
19,320 KB
testcase_24 AC 334 ms
28,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
n, k, x, y = map(int, input().split())
A = list(map(int, input().split()))
c = Counter()
tot = 0
for a in A:
	c[(a-2)//k+1] += 1
	tot += (a-2)//k+1

ans = tot * x
l = sorted(list(c.items()))

tmp_key = 0
tmp_val = n
for i in range(len(l)):
	key, val = l[i]
	tot -= (key-tmp_key) * tmp_val
	tmp_val -= val
	tmp_key = key
	ans = min(ans, tot * x + key * y)

print(ans)
0