結果

問題 No.1071 ベホマラー
ユーザー 小野寺健小野寺健
提出日時 2021-11-06 10:11:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-04-24 20:10:04
合計ジャッジ時間 5,457 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,032 KB
testcase_01 AC 83 ms
12,032 KB
testcase_02 AC 80 ms
12,288 KB
testcase_03 AC 81 ms
12,032 KB
testcase_04 AC 79 ms
12,160 KB
testcase_05 AC 81 ms
12,416 KB
testcase_06 AC 82 ms
12,160 KB
testcase_07 AC 82 ms
12,288 KB
testcase_08 AC 83 ms
12,288 KB
testcase_09 AC 79 ms
12,032 KB
testcase_10 AC 238 ms
18,176 KB
testcase_11 AC 231 ms
18,176 KB
testcase_12 AC 176 ms
16,128 KB
testcase_13 AC 221 ms
17,664 KB
testcase_14 AC 243 ms
18,688 KB
testcase_15 AC 270 ms
20,352 KB
testcase_16 AC 269 ms
20,224 KB
testcase_17 AC 271 ms
20,224 KB
testcase_18 AC 266 ms
19,968 KB
testcase_19 AC 269 ms
20,224 KB
testcase_20 AC 134 ms
20,224 KB
testcase_21 AC 129 ms
20,224 KB
testcase_22 AC 129 ms
20,224 KB
testcase_23 AC 131 ms
20,352 KB
testcase_24 AC 262 ms
20,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K, X, Y = gets.split(" ").map{|s| s.to_i}
a = gets.split(" ").map{|s| s.to_i}

a.sort!

h = 1
m = 0

i = a.bsearch_index{|x| x > h}
if i then
	n = N - i
	minh = a[i] - h
else
	n = 0
	minh = 0
end

while n > 0 do
	v = n * X > Y ? Y : n * X
	p = (K - 1 + minh) / K
	m += p * v
	h += K * p
	i = a.bsearch_index{|x| x > h}
	if i then
		n = N - i
		minh = a[i] - h
	else
		n = 0
		minh = 0
	end
end

puts m
0