結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 rin204rin204
提出日時 2024-04-07 15:45:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 104,856 KB
最終ジャッジ日時 2024-04-07 15:45:40
合計ジャッジ時間 9,651 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 47 ms
62,116 KB
testcase_02 AC 47 ms
62,116 KB
testcase_03 AC 52 ms
64,196 KB
testcase_04 AC 50 ms
64,180 KB
testcase_05 AC 49 ms
62,108 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 38 ms
53,456 KB
testcase_09 AC 378 ms
101,900 KB
testcase_10 AC 49 ms
62,116 KB
testcase_11 AC 42 ms
59,704 KB
testcase_12 AC 47 ms
62,116 KB
testcase_13 AC 51 ms
62,116 KB
testcase_14 AC 47 ms
62,116 KB
testcase_15 AC 38 ms
53,460 KB
testcase_16 AC 47 ms
62,116 KB
testcase_17 AC 48 ms
62,096 KB
testcase_18 AC 47 ms
62,116 KB
testcase_19 AC 46 ms
62,116 KB
testcase_20 AC 38 ms
53,460 KB
testcase_21 AC 37 ms
53,460 KB
testcase_22 AC 52 ms
64,196 KB
testcase_23 AC 52 ms
64,196 KB
testcase_24 AC 132 ms
81,968 KB
testcase_25 AC 138 ms
82,532 KB
testcase_26 AC 130 ms
81,724 KB
testcase_27 AC 138 ms
82,296 KB
testcase_28 AC 127 ms
81,356 KB
testcase_29 AC 250 ms
91,624 KB
testcase_30 AC 228 ms
89,100 KB
testcase_31 AC 256 ms
91,960 KB
testcase_32 AC 242 ms
91,184 KB
testcase_33 AC 239 ms
90,580 KB
testcase_34 AC 409 ms
104,856 KB
testcase_35 AC 393 ms
103,356 KB
testcase_36 AC 390 ms
102,200 KB
testcase_37 AC 405 ms
104,276 KB
testcase_38 AC 390 ms
102,912 KB
testcase_39 AC 180 ms
85,920 KB
testcase_40 AC 130 ms
82,136 KB
testcase_41 AC 149 ms
83,516 KB
testcase_42 AC 126 ms
81,892 KB
testcase_43 AC 177 ms
85,764 KB
testcase_44 AC 140 ms
82,800 KB
testcase_45 AC 112 ms
80,372 KB
testcase_46 AC 64 ms
76,124 KB
testcase_47 AC 139 ms
80,528 KB
testcase_48 AC 142 ms
82,924 KB
testcase_49 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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, a2 * a3, a3 * a1)
ma = min(ma, n)
dp = [0] * (ma + 1)
for i in range(ma + 1):
    if i >= a1:
        dp[i] = max(dp[i], dp[i - a1] + b1)
    if i >= a2:
        dp[i] = max(dp[i], dp[i - a2] + b2)
    if i >= a3:
        dp[i] = max(dp[i], dp[i - a3] + b3)

ans = 0
for i in range(ma + 1):
    for a, b in [(a1, b1), (a2, b2), (a3, b3)]:
        tot = dp[i]
        tot += (n - i) // a * b
        ans = max(ans, tot)

print(ans)
0