結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 MizarMizar
提出日時 2023-06-29 21:01:05
言語 JavaScript
(node v21.7.1)
結果
TLE  
実行時間 -
コード長 767 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 5,372 KB
実行使用メモリ 51,724 KB
最終ジャッジ日時 2023-09-26 08:03:15
合計ジャッジ時間 6,010 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
46,648 KB
testcase_01 AC 86 ms
43,112 KB
testcase_02 AC 144 ms
46,824 KB
testcase_03 AC 126 ms
47,008 KB
testcase_04 AC 120 ms
47,212 KB
testcase_05 AC 586 ms
46,864 KB
testcase_06 AC 78 ms
42,068 KB
testcase_07 AC 78 ms
42,256 KB
testcase_08 AC 78 ms
42,268 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
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 = BigInt(l[0]);
let [a0, b0] = l[1].split(" ").map(s => BigInt(s));
let [a1, b1] = l[2].split(" ").map(s => BigInt(s));
let [a2, b2] = l[3].split(" ").map(s => BigInt(s));

function co_solve(n, ar, br, as, bs, at, bt) {
	let r = 0n;
	for (let i = 0n, di = n; i < ar && di >= 0n; i += 1n, di -= as) {
		for (let j = 0n, dj = di; j < ar && dj >= 0n; j += 1n, dj -= at) {
			let t = (dj / ar) * br + i * bs + j * bt;
			r = (r < t) ? t : r;
		}
	}
	return r;
}

let r1 = co_solve(n, a0, b0, a1, b1, a2, b2);
let r2 = co_solve(n, a1, b1, a2, b2, a0, b0);
let r3 = co_solve(n, a2, b2, a0, b0, a1, b1);

let r = r1;
r = (r < r2) ? r2 : r;
r = (r < r3) ? r3 : r;

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