第一个点TLE求助
查看原帖
第一个点TLE求助
1451143
czl92783719楼主2024/10/5 15:37
def dfs(ls1,le,su,p,s,oe):
    if (oe and s>=su//2) or ((not oe) and s>su//2):
        return s
    elif p==le:
        return su
    else:
        return min(list(map(dfs,[ls1]*(le-p),[le]*(le-p),[su]*(le-p),range(p+1,le+1),list(map(lambda x:s+ls1[x],range(p,le))),[oe]*(le-p))))
t=0
sl=list(map(int,input().split()))
for i1 in range(4):
    ll=list(map(int,input().split()))
    t+=dfs(ll,len(ll),sum(ll),0,0,sum(ll)%2==0)
print(t)
2024/10/5 15:37
加载中...