我用了很多题解 但是还是会莫名wa或莫名re
比如代码:这是仿照题解写的:
n,m= map(int,input().split())
a = [0]+list(sorted(list(map(int,input().split())),reverse =True))+[0]*2020
b = [0]+list(sorted(list(map(int,input().split())),reverse =True))+[0]*2020
ans =0
sa= 1
sb= 1
while sa<n and sb<m:
if a[sa]>b[sb]:
ans+=a[sa]*sb
sa+=1
else:
ans+=b[sb]*sa
sb+=1
while sa<n:
ans+=a[sa]*sb
sa+=1
while sb<m:
ans+=b[sb]*sa
sb+=1
print(ans)
还是wa,我没有很理解