結果

問題 No.2390 Udon Coupon (Hard)
ユーザー titiatitia
提出日時 2023-11-20 02:47:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,114 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 63,948 KB
最終ジャッジ日時 2023-11-20 02:47:47
合計ジャッジ時間 4,403 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 WA -
testcase_02 AC 41 ms
55,584 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 51 ms
63,948 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 43 ms
55,584 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 38 ms
53,460 KB
testcase_12 AC 38 ms
53,460 KB
testcase_13 AC 37 ms
53,460 KB
testcase_14 AC 38 ms
53,460 KB
testcase_15 AC 38 ms
53,460 KB
testcase_16 AC 38 ms
53,460 KB
testcase_17 AC 37 ms
53,460 KB
testcase_18 AC 38 ms
53,460 KB
testcase_19 AC 37 ms
53,460 KB
testcase_20 AC 37 ms
53,460 KB
testcase_21 AC 36 ms
53,460 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 38 ms
53,460 KB
testcase_25 AC 39 ms
53,460 KB
testcase_26 AC 39 ms
53,460 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 40 ms
53,460 KB
testcase_30 WA -
testcase_31 AC 40 ms
53,460 KB
testcase_32 AC 40 ms
53,460 KB
testcase_33 WA -
testcase_34 AC 40 ms
55,584 KB
testcase_35 AC 40 ms
55,584 KB
testcase_36 AC 40 ms
55,584 KB
testcase_37 AC 40 ms
55,584 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 41 ms
55,584 KB
testcase_42 AC 41 ms
55,584 KB
testcase_43 AC 43 ms
55,584 KB
testcase_44 AC 39 ms
53,460 KB
testcase_45 WA -
testcase_46 AC 39 ms
53,460 KB
testcase_47 AC 41 ms
55,584 KB
testcase_48 AC 42 ms
55,584 KB
testcase_49 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
AB=[list(map(int,input().split())) for i in range(3)]

X=[AB[i][1]/AB[i][0] for i in range(3)]

ANS=0

MIN=0
MAX=N//AB[0][0]

while MAX-MIN>5:
    mid1=MIN+(MAX-MIN)//3
    mid2=MIN+(MAX-MIN)//3*2
    
    rest=N-mid1*AB[0][0]
    MIN2=0
    MAX2=rest//AB[1][0]

    while MAX2-MIN2>5:
        mid01=MIN2+(MAX2-MIN2)//3
        mid02=MIN2+(MAX2-MIN2)//3*2

        rest2=rest-mid01*AB[1][0]
        c1=mid1*AB[0][1]+mid01*AB[1][1]+(rest2//AB[2][0])*AB[2][1]

        rest2=rest-mid02*AB[1][0]
        c2=mid1*AB[0][1]+mid02*AB[1][1]+(rest2//AB[2][0])*AB[2][1]

        if c1>c2:
            MAX2=mid02
        else:
            MIN2=mid01

    A1=0

    for j in range(MIN2,MAX2+1):
        rest2=rest-j*AB[1][0]
        A1=max(A1,mid1*AB[0][1]+j*AB[1][1]+(rest2//AB[2][0])*AB[2][1])

    rest=N-mid2*AB[0][0]
    MIN2=0
    MAX2=rest//AB[1][0]

    while MAX2-MIN2>5:
        mid01=MIN2+(MAX2-MIN2)//3
        mid02=MIN2+(MAX2-MIN2)//3*2

        rest2=rest-mid01*AB[1][0]
        c1=mid2*AB[0][1]+mid01*AB[1][1]+(rest2//AB[2][0])*AB[2][1]

        rest2=rest-mid02*AB[1][0]
        c2=mid2*AB[0][1]+mid02*AB[1][1]+(rest2//AB[2][0])*AB[2][1]

        if c1>c2:
            MAX2=mid02
        else:
            MIN2=mid01

    A2=0

    for j in range(MIN2,MAX2+1):
        rest2=rest-j*AB[1][0]
        A2=max(A2,mid2*AB[0][1]+j*AB[1][1]+(rest2//AB[2][0])*AB[2][1])

    if A1>A2:
        MAX=mid2
    else:
        MIN=mid1

ANS=0

for mid in range(MIN,MAX+1):
    rest=N-mid*AB[0][0]
    MIN2=0
    MAX2=rest//AB[1][0]

    while MAX2-MIN2>5:
        mid01=MIN2+(MAX2-MIN2)//3
        mid02=MIN2+(MAX2-MIN2)//3*2

        rest2=rest-mid01*AB[1][0]
        c1=mid*AB[0][1]+mid01*AB[1][1]+(rest2//AB[2][0])*AB[2][1]

        rest2=rest-mid02*AB[1][0]
        c2=mid*AB[0][1]+mid02*AB[1][1]+(rest2//AB[2][0])*AB[2][1]

        if c1>c2:
            MAX2=mid02
        else:
            MIN2=mid01

    for j in range(MIN2,MAX2+1):
        rest2=rest-j*AB[1][0]
        ANS=max(ANS,mid*AB[0][1]+j*AB[1][1]+(rest2//AB[2][0])*AB[2][1])
    

        

print(ANS)
0