結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 Mizar
提出日時 2023-06-29 18:34:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 639 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 44,356 KB
最終ジャッジ日時 2024-10-06 01:30:25
合計ジャッジ時間 28,555 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

def co_solve(n, a0, b0, a1, b1, a2, b2):
	r = 0
	for i in range(min(a0, n // a1 + 1)):
		d = n - i * a1
		jmax = min(a0, d // a2 + 1)
		j = np.arange(0, jmax, dtype=np.uint64)
		t = ((d - j * a2) // a0) * b0 + i * b1 + j * b2
		r = max(r, np.amax(t))
	return r

n = int(input())
a0, b0 = (int(x) for x in input().split())
a1, b1 = (int(x) for x in input().split())
a2, b2 = (int(x) for x in input().split())

result = max(
	co_solve(n, a0, b0, a1, b1, a2, b2),
	co_solve(n, a1, b1, a2, b2, a0, b0),
	co_solve(n, a2, b2, a0, b0, a1, b1),
)

print(result)
0