memory

MikeLi發表於2024-10-31
import pdb
#pdb.set_trace()
ad={}
al=[]
#a="64:2,128:1,32:4,1:128"
list1=input().split(',')
#list1=[]
for i in list1:
    #ad.append(dict(i.split(':')))
    tmp=i.split(':')
    ad[int(tmp[0])]=int(tmp[1])
#b="50,36,64,128,127"
list2=input().split(',')
for i in list2:
    al.append(int(i))

#print(ad)
#print(al)

#mems=sorted(ad)
#print(ad_new)
out=""


mems=sorted(ad)
cur=0
for i in al:
    rs="false"
    if mems[cur]>=i and ad[mems[cur]]>=1:
        rs="true"
        if ad[mems[cur]]==1:
            del ad[mems[cur]]
            del mems[cur]
            cur=0
        else:
            ad[mems[cur]]=ad[mems[cur]]-1
        
    else:
        for j in range(0,len(mems)):
            if mems[j]>=i and ad[mems[j]]>=1:
                rs="true"
                cur=j
                if ad[mems[j]]==1:
                    del ad[mems[j]]
                    del mems[j]
                    cur=0
                else:
                    ad[mems[j]]=ad[mems[j]]-1
                break
    out=out+str(rs)+","
print(out[0:len(out)-1])







#for i in al:
#    mems=sorted(ad)
#    rs="false"
#
#    for j in mems:
#        if j<i:
#            continue
#        else:
#            last=j-i
#            if last==0:
#                del ad[j]
#            elif ad[j]==1:
#                del ad[j]
#            else:
#                num=ad[j]
#                del ad[j]
#                ad[j]=num-1
#            rs="true"
#            break
#    out=out+str(rs)+","
#print(out[0:len(out)-1])

相關文章