結果

問題 No.2390 Udon Coupon (Hard)
コンテスト
ユーザー norioc
提出日時 2025-10-29 02:26:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 951 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2025-10-29 02:26:43
合計ジャッジ時間 17,166 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations, product

N = int(input())
A1, B1 = map(int, input().split())
A2, B2 = map(int, input().split())
A3, B3 = map(int, input().split())

ma = max(A1, A2, A3)
ans = 0
for a, b, c in permutations([(A1, B1), (A2, B2), (A3, B3)]):
    for i, j in product(range(ma+1), repeat=2):
        rest = N - a[0] * i - b[0] * j
        if rest < 0: continue

        v = a[1] * i + b[1] * j + c[1] * (rest // c[0])
        ans = max(ans, v)

print(ans)
0