結果

問題 No.2390 Udon Coupon (Hard)
ユーザー shogo314shogo314
提出日時 2023-07-21 23:17:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 689 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 80,088 KB
最終ジャッジ日時 2023-10-21 23:17:59
合計ジャッジ時間 9,669 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,644 KB
testcase_01 AC 39 ms
53,556 KB
testcase_02 AC 51 ms
62,344 KB
testcase_03 AC 59 ms
62,356 KB
testcase_04 AC 56 ms
62,356 KB
testcase_05 AC 63 ms
62,344 KB
testcase_06 AC 40 ms
53,556 KB
testcase_07 AC 38 ms
53,556 KB
testcase_08 AC 39 ms
53,556 KB
testcase_09 AC 49 ms
62,396 KB
testcase_10 AC 39 ms
53,556 KB
testcase_11 AC 41 ms
53,556 KB
testcase_12 AC 66 ms
64,512 KB
testcase_13 AC 46 ms
59,772 KB
testcase_14 AC 40 ms
53,556 KB
testcase_15 AC 40 ms
53,556 KB
testcase_16 AC 39 ms
53,556 KB
testcase_17 AC 46 ms
59,772 KB
testcase_18 AC 49 ms
60,284 KB
testcase_19 AC 48 ms
60,284 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 133 ms
62,344 KB
testcase_40 AC 332 ms
66,444 KB
testcase_41 AC 1,901 ms
73,756 KB
testcase_42 AC 238 ms
66,460 KB
testcase_43 AC 64 ms
64,412 KB
testcase_44 TLE -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N = int(input())
AB = [tuple(map(int, input().split())) for i in range(3)]
ans = 0
g = 1
for A, B in AB:
    g = g*A//math.gcd(g, A)
for A, B in AB:
    ans = max(ans, N//g*((g//A)*B))
N %= g
g=AB[1][0]*AB[2][0]//math.gcd(AB[1][0],AB[2][0])
h=max([(g//A)*B for A,B in AB[1:]])
tmp_max=0
for i in range(N+1):
    if AB[0][0]*i>N:
        break
    tmp=AB[0][1]*i
    m=N-AB[0][0]*i
    tmp+=(m//g)*h
    m%=g
    tmp_max_=0
    for j in range(m+1):
        if AB[1][0]*j>m:
            break
        tmp_=AB[1][1]*j
        o=m-j*AB[1][0]
        tmp_+=AB[2][1]*(o//AB[2][0])
        tmp_max_=max(tmp_max_,tmp_)
    tmp+=tmp_max_
    tmp_max=max(tmp,tmp_max)
print(ans+tmp_max)
0