QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#679484#7678. The GamemengxinzclCompile Error//Python31.2kb2024-10-26 17:43:192024-10-26 17:43:20

Judging History

你现在查看的是最新测评结果

  • [2024-10-26 17:43:20]
  • 评测
  • [2024-10-26 17:43:19]
  • 提交

answer

from collections import deque
for i in range(int(input())):
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    a.sort()
    b.sort()
    suma=sum(a[-m::])
    sumb=sum(b)
     k=sumb-suma
    if k<0:
        print(-1)
        continue
    
    ms=a[-m::]
    minmi=0
    res=[]
    if n-m>k:        #tk 为总和差值,cz为总操作数
        cz=n-m
        tk=k+0
        xl=deque(a[0:-m])
        while cz>tk and xl:
            if xl[0]>ms[0]:
                cz-=1
                res.append(xl.popleft())
        for i in range(m-1,-1,-1):
            if ms[i]<=b[i]:
                for j in range(b[i]-ms[i]):
                    res.append(ms[i])
                    ms[i]+=1
            else:
                res=-1
                break 
            
            
            
    elif n-m==k:
        for i in range(m-1,-1,-1):
            if ms[i]<=b[i]:
                for j in range(b[i]-ms[i]):
                    res.append(ms[i])
                    ms[i]+=1
            else:
                res=-1
                break          
    elif n-m<k:
        print(-1)
        continue
    print(*res)

详细

Sorry: IndentationError: unexpected indent (answer.code, line 10)