Problem p03290 (python)

Fixed submission:
d,g = map(int,input().split())
q={}
comp={}
p={}
minsolve=0
for i in range(d):
    a,b=map(int,input().split())
    q[i]=a
    p[i]=100*(i+1)
    comp[i]=100*(i+1)*a+b
    minsolve+=a
    
solve=[0 for _ in range(d)]
def roop(s,check,point,solved,minsolve):
    solve=s.copy()
    solve2=s.copy()
    if check==d:
        if point>g:
            minsolve=min(minsolve,solved)
            return minsolve
        if 0 in solve:
            solverev=solve.copy()
            solverev.reverse()
            idx=d-solverev.index(0)-1
            shold=1+(g-point-1)//p[idx]
            if q[idx]>shold and shold>=0:
                solved+=shold
                minsolve=min(minsolve,solved)
        return minsolve

    minsolve=roop(solve,check+1,point,solved,minsolve)
    solve2[check]+=1
    minsolve=roop(solve2,check+1,point+comp[check],solved+q[check],minsolve)
    return minsolve

print(roop(solve,0,0,0,minsolve))

Buggy submission (verdict: Runtime Error):
#2-1-1 #ABC104C
d,g=map(int,input().split())
q=[]
comp=[]
bornus=[]
for i in range(d):
    p,c=map(int,input().split())
    q.append(p)
    bornus.append(100*(i+1)*p+c)
    comp.append((100*(i+1)*p+c)/p)
    
p=[100*i for i in range(1,d+1)]
    
data={0:[0 for i in range(d)]}
def makemax(p,q,bornus,comp,k):
    now=0
    point=0
    pnow=p.copy()
    qnow=q.copy()
    bornusnow=bornus.copy()
    compnow=comp.copy()
    while now<k:
        compnown=compnow.copy()
        kagen=max(pnow)
        kagenidx=pnow.index(kagen)
        kagen_num=qnow[kagenidx]
        for i in range(d):
            maxcomp=max(compnown)
            compnown.pop(compnow.index(maxcomp))
            maxidx=compnow.index(maxcomp)
            if maxcomp<kagen:break
            if qnow[maxidx]>k-now:continue
            point+=bornusnow[maxidx]
            now+=qnow[maxidx]
            compnow[maxidx]=0
            pnow[maxidx]=0
            if maxidx==kagenidx:
                if len(pnow)!=0:
                    kagen=max(pnow)
                    kagenidx=pnow.index(kagen)
                    kagen_num=qnow[kagenidx]
                else:
                    kagen=-1
        if kagen==-1:break
        adit=min(k-now,kagen_num)
        if adit==kagen_num:
            point+=bornusnow[kagenidx]
            now+=kagen_num
        elif adit<kagen_num:
            point+=adit*kagen
            now+=adit
        compnow[kagenidx]=0
        pnow[kagenidx]=0
    return point

ans=-1
k=0
while ans==-1:
    if makemax(p,q,bornus,comp,k)>=g:
        ans=k
        
    k+=1
print(ans)

Buggy submission (verdict: Runtime Error):
#2-1-1 #ABC104C
d,g=map(int,input().split())
q=[]
comp=[]
bornus=[]
for i in range(d):
    p,c=map(int,input().split())
    q.append(p)
    bornus.append(100*(i+1)*p+c)
    comp.append((100*(i+1)*p+c)/p)
    
p=[100*i for i in range(1,d+1)]
    
data={0:[0 for i in range(d)]}
def makemax(p,q,bornus,comp,k):
    now=0
    point=0
    pnow=p.copy()
    qnow=q.copy()
    bornusnow=bornus.copy()
    compnow=comp.copy()
    while now<k:
        compnown=compnow.copy()
        kagen=max(pnow)
        kagenidx=pnow.index(kagen)
        kagen_num=qnow[kagenidx]
        for i in range(d):
            maxcomp=max(compnown)
            compnown.pop(compnow.index(maxcomp))
            maxidx=compnow.index(maxcomp)
            if maxcomp<kagen:break
            if qnow[maxidx]>k-now:continue
            point+=bornusnow[maxidx]
            now+=qnow[maxidx]
            compnow[maxidx]=0
            pnow[maxidx]=0
            if maxidx==kagenidx:
                kagen=max(pnow)
                kagenidx=pnow.index(kagen)
                kagen_num=qnow[kagenidx]
        adit=min(k-now,kagen_num)
        if adit==kagen_num:
            point+=bornusnow[kagenidx]
            now+=kagen_num
        elif adit<kagen_num:
            point+=adit*kagen
            now+=adit
        compnow[kagenidx]=0
        pnow[kagenidx]=0
    return point

ans=-1
k=0
while ans==-1:
    if makemax(p,q,bornus,comp,k)>=g:
        ans=k
        
    k+=1
print(ans)