結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 MizarMizar
提出日時 2023-07-07 20:17:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 529 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 12,636 KB
最終ジャッジ日時 2023-09-29 06:35:47
合計ジャッジ時間 5,906 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,948 KB
testcase_01 AC 17 ms
8,296 KB
testcase_02 AC 25 ms
8,328 KB
testcase_03 AC 34 ms
8,216 KB
testcase_04 AC 31 ms
8,260 KB
testcase_05 AC 18 ms
8,188 KB
testcase_06 AC 16 ms
7,776 KB
testcase_07 AC 16 ms
7,804 KB
testcase_08 AC 16 ms
7,840 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 #

n = int(input())
[[a1, b1], [a2, b2], [a3, b3]] = [list(map(int, input().split())) for _ in range(3)]
amin, bmin = min(a1, a2, a3), min(b1, b2, b3)
assert n > 0 and amin > 0 and bmin > 0
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
w = max(n // a1 - a2 - a3, 0)
m = n - w * a1 + 1
dp = [-1 << 60] * 2048
r = 0
for i in range(m):
	dp[i & 2047] = r = max(
		dp[(i - a1) & 2047] + b1,
		dp[(i - a2) & 2047] + b2,
		dp[(i - a3) & 2047] + b3,
		r,
	)
print(r + w * b1)
0