結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 MizarMizar
提出日時 2023-07-03 21:53:12
言語 JavaScript
(node v21.7.1)
結果
TLE  
実行時間 -
コード長 815 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 5,328 KB
実行使用メモリ 52,884 KB
最終ジャッジ日時 2023-09-26 08:16:39
合計ジャッジ時間 23,586 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
44,440 KB
testcase_01 AC 84 ms
42,920 KB
testcase_02 AC 158 ms
47,608 KB
testcase_03 AC 110 ms
47,596 KB
testcase_04 AC 110 ms
47,372 KB
testcase_05 AC 282 ms
47,304 KB
testcase_06 AC 75 ms
42,308 KB
testcase_07 AC 78 ms
42,180 KB
testcase_08 AC 76 ms
42,176 KB
testcase_09 TLE -
testcase_10 AC 96 ms
47,376 KB
testcase_11 AC 78 ms
42,360 KB
testcase_12 AC 100 ms
47,200 KB
testcase_13 AC 104 ms
47,548 KB
testcase_14 AC 106 ms
47,380 KB
testcase_15 AC 79 ms
42,620 KB
testcase_16 AC 95 ms
47,592 KB
testcase_17 AC 94 ms
47,244 KB
testcase_18 AC 104 ms
47,456 KB
testcase_19 AC 106 ms
47,508 KB
testcase_20 AC 76 ms
42,216 KB
testcase_21 AC 77 ms
42,148 KB
testcase_22 AC 110 ms
47,484 KB
testcase_23 AC 111 ms
47,220 KB
testcase_24 AC 887 ms
47,240 KB
testcase_25 AC 939 ms
47,224 KB
testcase_26 AC 902 ms
47,396 KB
testcase_27 AC 933 ms
49,452 KB
testcase_28 AC 858 ms
47,480 KB
testcase_29 AC 1,801 ms
47,672 KB
testcase_30 AC 1,611 ms
47,456 KB
testcase_31 AC 1,816 ms
47,500 KB
testcase_32 AC 1,781 ms
47,688 KB
testcase_33 AC 1,741 ms
47,612 KB
testcase_34 TLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

function solve(n, ap, bp, aq, bq, ar, br) {
	let r = 0, imax = ap * bq, jmax = ap * br;
	for (let i = 0, di = n; i < imax && di >= 0; i += bq, di -= aq) {
		for (let j = 0, dj = di; j < jmax && dj >= 0; j += br, dj -= ar) {
			let t = BigInt(Math.floor(dj / ap)) * BigInt(bp) + BigInt(i + j);
			r = (r < t) ? t : r;
		}
	}
	return r;
}

let r1 = solve(n, a0, b0, a1, b1, a2, b2);
let r2 = solve(n, a1, b1, a2, b2, a0, b0);
let r3 = solve(n, a2, b2, a0, b0, a1, b1);
let r = (r1 > r2 && r1 > r3) ? r1 : (r2 > r3) ? r2 : r3;
console.log(r.toString());
0