結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 MizarMizar
提出日時 2023-07-04 03:38:02
言語 Ruby
(3.3.0)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-15 20:51:58
合計ジャッジ時間 8,553 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,032 KB
testcase_01 AC 80 ms
12,160 KB
testcase_02 AC 84 ms
11,904 KB
testcase_03 AC 83 ms
12,160 KB
testcase_04 AC 84 ms
12,288 KB
testcase_05 AC 139 ms
12,288 KB
testcase_06 AC 88 ms
11,904 KB
testcase_07 AC 83 ms
12,160 KB
testcase_08 AC 82 ms
12,160 KB
testcase_09 AC 217 ms
12,160 KB
testcase_10 AC 83 ms
12,288 KB
testcase_11 AC 80 ms
12,160 KB
testcase_12 AC 81 ms
12,032 KB
testcase_13 AC 82 ms
12,160 KB
testcase_14 AC 85 ms
12,160 KB
testcase_15 AC 86 ms
12,032 KB
testcase_16 AC 87 ms
12,160 KB
testcase_17 AC 86 ms
12,160 KB
testcase_18 AC 84 ms
12,160 KB
testcase_19 AC 84 ms
12,288 KB
testcase_20 AC 82 ms
12,160 KB
testcase_21 AC 82 ms
12,160 KB
testcase_22 AC 83 ms
12,032 KB
testcase_23 AC 83 ms
12,160 KB
testcase_24 AC 134 ms
12,160 KB
testcase_25 AC 137 ms
12,160 KB
testcase_26 AC 144 ms
12,288 KB
testcase_27 AC 138 ms
12,160 KB
testcase_28 AC 132 ms
12,160 KB
testcase_29 AC 236 ms
11,904 KB
testcase_30 AC 231 ms
12,288 KB
testcase_31 AC 235 ms
12,288 KB
testcase_32 AC 235 ms
12,160 KB
testcase_33 AC 241 ms
12,160 KB
testcase_34 AC 378 ms
12,160 KB
testcase_35 AC 360 ms
12,160 KB
testcase_36 AC 356 ms
12,288 KB
testcase_37 AC 354 ms
12,032 KB
testcase_38 AC 362 ms
12,160 KB
testcase_39 AC 232 ms
12,160 KB
testcase_40 AC 172 ms
12,160 KB
testcase_41 AC 218 ms
12,160 KB
testcase_42 AC 167 ms
12,160 KB
testcase_43 AC 156 ms
12,160 KB
testcase_44 AC 84 ms
12,288 KB
testcase_45 AC 97 ms
12,160 KB
testcase_46 AC 85 ms
12,160 KB
testcase_47 AC 81 ms
12,032 KB
testcase_48 AC 91 ms
11,904 KB
testcase_49 AC 82 ms
11,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a1, b1 = gets.split.map(&:to_i)
a2, b2 = gets.split.map(&:to_i)
a3, b3 = gets.split.map(&:to_i)

exit(false) unless n > 0 && a1 > 0 && a2 > 0 && a3 > 0 && b1 > 0 && b2 > 0 && b3 > 0

a1, b1, a2, b2 = a2, b2, a1, b1 if a2 * b1 < a1 * b2
a1, b1, a3, b3 = a3, b3, a1, b1 if a3 * b1 < a1 * b3

a1b2, a1b3 = a1 * b2, a1 * b3
r, p, s = 0, 0, n
while p < a1b2 && s >= 0 do
	q, t = 0, s
	while q < a1b3 && t >= 0 do
		r = [r, t / a1 * b1 + p + q].max
		t -= a3
		q += b3
	end
	s -= a2
	p += b2
end

puts r
0