結果

問題 No.2390 Udon Coupon (Hard)
ユーザー mymelochanmymelochan
提出日時 2023-07-21 23:18:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,291 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 145,908 KB
最終ジャッジ日時 2023-10-21 23:18:57
合計ジャッジ時間 8,157 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
62,640 KB
testcase_01 AC 54 ms
64,832 KB
testcase_02 AC 144 ms
145,768 KB
testcase_03 AC 203 ms
145,888 KB
testcase_04 AC 181 ms
145,880 KB
testcase_05 AC 48 ms
63,844 KB
testcase_06 WA -
testcase_07 AC 40 ms
55,448 KB
testcase_08 AC 39 ms
55,448 KB
testcase_09 AC 188 ms
136,428 KB
testcase_10 AC 48 ms
62,628 KB
testcase_11 AC 47 ms
64,052 KB
testcase_12 AC 47 ms
62,168 KB
testcase_13 AC 46 ms
62,172 KB
testcase_14 AC 49 ms
64,904 KB
testcase_15 AC 51 ms
64,060 KB
testcase_16 AC 50 ms
64,888 KB
testcase_17 AC 48 ms
64,040 KB
testcase_18 AC 49 ms
64,468 KB
testcase_19 AC 47 ms
64,460 KB
testcase_20 AC 40 ms
55,448 KB
testcase_21 AC 42 ms
55,448 KB
testcase_22 AC 142 ms
134,304 KB
testcase_23 AC 140 ms
132,112 KB
testcase_24 AC 169 ms
134,368 KB
testcase_25 AC 171 ms
134,368 KB
testcase_26 AC 171 ms
136,416 KB
testcase_27 AC 170 ms
134,368 KB
testcase_28 AC 174 ms
140,528 KB
testcase_29 AC 183 ms
136,428 KB
testcase_30 AC 200 ms
145,908 KB
testcase_31 AC 186 ms
138,480 KB
testcase_32 AC 181 ms
136,428 KB
testcase_33 AC 205 ms
145,908 KB
testcase_34 AC 180 ms
136,428 KB
testcase_35 AC 181 ms
136,428 KB
testcase_36 AC 183 ms
136,428 KB
testcase_37 AC 184 ms
138,480 KB
testcase_38 AC 204 ms
145,908 KB
testcase_39 AC 100 ms
92,820 KB
testcase_40 AC 141 ms
134,368 KB
testcase_41 AC 186 ms
134,384 KB
testcase_42 AC 167 ms
134,360 KB
testcase_43 AC 186 ms
136,432 KB
testcase_44 AC 163 ms
134,240 KB
testcase_45 AC 161 ms
136,428 KB
testcase_46 AC 138 ms
142,420 KB
testcase_47 AC 156 ms
136,408 KB
testcase_48 AC 159 ms
134,368 KB
testcase_49 AC 42 ms
55,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations

ipt = sys.stdin.readline

def iin():
    return int(ipt())
def lmin():
    return list(map(int,ipt().split()))

MOD = 998244353
inf = 1<<60
#############################################################

M = 3000**2

N = iin()
A1,B1 = lmin()
A2,B2 = lmin()
A3,B3 = lmin()

if N < M:
    dp = [-inf]*(N+1)
    dp[0] = 0
    for i in range(1,N+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)
    print(max(dp))
else:
    L = N-M
    r = (L+A1-1)//A1
    t = r*A1
    
    dp = [-inf]*(M+1)
    dp[t-L] = B1*r

    r = (L+A2-1)//A2
    t = r*A2
    
    dp[t-L] = B2*r

    r = (L+A3-1)//A3
    t = r*A3

    dp[t-L] = B3*r

    for i in range(1,M+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)
    print(max(dp))
0