結果

問題 No.2390 Udon Coupon (Hard)
ユーザー titiatitia
提出日時 2023-11-20 02:56:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 62,464 KB
最終ジャッジ日時 2024-09-26 06:32:12
合計ジャッジ時間 5,614 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

AB.sort(reverse=True)

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

MAX=max(X)
ind=X.index(MAX)

a,b=AB[ind]
xx=AB[0][0]*AB[1][0]*2

k=max(0,N-xx)//a

ANS=k*b
N-=k*a

ANS2=0
for i in range(N//AB[0][0]+1):
    rest=N-i*AB[0][0]
    for j in range(rest//AB[1][0]+1):
        ANS2=max(ANS2,i*AB[0][1]+j*AB[1][1]+(rest-j*AB[1][0])//AB[2][0]*AB[2][1])

print(ANS+ANS2)
0