結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 MizarMizar
提出日時 2023-07-04 03:11:28
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 45,044 KB
最終ジャッジ日時 2024-04-15 20:52:20
合計ジャッジ時間 7,853 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
39,296 KB
testcase_01 AC 69 ms
39,552 KB
testcase_02 AC 70 ms
39,680 KB
testcase_03 AC 72 ms
40,576 KB
testcase_04 AC 66 ms
40,448 KB
testcase_05 AC 135 ms
44,792 KB
testcase_06 AC 63 ms
39,168 KB
testcase_07 AC 61 ms
39,424 KB
testcase_08 AC 62 ms
39,296 KB
testcase_09 AC 188 ms
44,656 KB
testcase_10 AC 63 ms
39,680 KB
testcase_11 AC 62 ms
39,296 KB
testcase_12 AC 62 ms
39,296 KB
testcase_13 AC 62 ms
39,168 KB
testcase_14 AC 64 ms
39,296 KB
testcase_15 AC 61 ms
39,040 KB
testcase_16 AC 60 ms
39,040 KB
testcase_17 AC 63 ms
39,552 KB
testcase_18 AC 61 ms
39,680 KB
testcase_19 AC 63 ms
39,168 KB
testcase_20 AC 61 ms
39,168 KB
testcase_21 AC 60 ms
39,040 KB
testcase_22 AC 65 ms
40,832 KB
testcase_23 AC 65 ms
40,832 KB
testcase_24 AC 127 ms
44,788 KB
testcase_25 AC 130 ms
44,920 KB
testcase_26 AC 135 ms
44,784 KB
testcase_27 AC 129 ms
44,788 KB
testcase_28 AC 127 ms
44,788 KB
testcase_29 AC 201 ms
44,916 KB
testcase_30 AC 193 ms
44,916 KB
testcase_31 AC 195 ms
44,788 KB
testcase_32 AC 200 ms
44,660 KB
testcase_33 AC 198 ms
44,788 KB
testcase_34 AC 292 ms
45,044 KB
testcase_35 AC 282 ms
44,664 KB
testcase_36 AC 281 ms
44,788 KB
testcase_37 AC 290 ms
44,920 KB
testcase_38 AC 289 ms
44,664 KB
testcase_39 AC 198 ms
44,664 KB
testcase_40 AC 152 ms
44,788 KB
testcase_41 AC 192 ms
44,788 KB
testcase_42 AC 152 ms
44,660 KB
testcase_43 AC 146 ms
44,660 KB
testcase_44 AC 68 ms
40,320 KB
testcase_45 AC 100 ms
44,664 KB
testcase_46 AC 69 ms
41,088 KB
testcase_47 AC 63 ms
39,296 KB
testcase_48 AC 95 ms
44,656 KB
testcase_49 AC 62 ms
39,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let l = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
let n = BigInt(l[0]);
let [a1, b1] = l[1].split(" ").map(s => BigInt(s));
let [a2, b2] = l[2].split(" ").map(s => BigInt(s));
let [a3, b3] = l[3].split(" ").map(s => BigInt(s));

if (a2 * b1 < a1 * b2) {
	[a1, b1, a2, b2] = [a2, b2, a1, b1];
}
if (a3 * b1 < a1 * b3) {
	[a1, b1, a3, b3] = [a3, b3, a1, b1];
}

let r = 0n, a1b2 = a1 * b2, a1b3 = a1 * b3;
for (let p = 0n, s = n; p < a1b2 && s >= 0n; p += b2, s -= a2) {
	for (let q = 0n, t = s; q < a1b3 && t >= 0n; q += b3, t -= a3) {
		let u = t / a1 * b1 + p + q;
		r = (r < u) ? u : r;
	}
}

console.log(r.toString());
0