結果

問題 No.3537 Thank You!
コンテスト
ユーザー titia
提出日時 2026-05-08 23:17:25
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 763 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 409 ms
コンパイル使用メモリ 85,652 KB
実行使用メモリ 115,456 KB
最終ジャッジ日時 2026-05-08 23:17:38
合計ジャッジ時間 5,730 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サブタスク1 30 % AC * 18 WA * 3
サブタスク2 70 % AC * 15
合計 2.5 * 70% = 175 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

N=int(input())
B=int(input())
C=list(map(int,input().split()))
S=list(map(int,input().split()))

A=[]
for i in range(N):
    A.append((C[i],S[i]))

A.sort()

MAX=[0]*N

MAX[-1]=A[-1][1]

for i in range(N-2,-1,-1):
    MAX[i]=max(MAX[i+1],A[i][1])

MAX.append(0)

ANS=0
now=B
score=0

for i in range(N):
    nec=MAX[i+1]

    c,s=A[i]

    if now-c*s>=nec:
        now-=c*s
        score+=s

        ANS=max(ANS,score+nec)
    else:
        k=(now-nec)//c

        for j in range(k-3,k+4):
            if j>=1 and j<=s and now-j*c>=1:
                score2=score+j
                now2=now-j*c

                ANS=max(ANS,score2+min(nec,now2))

        k=now//c

        now-=c*k
        score+=k

print(ANS)
        
    
0