蓝桥杯刷新(九)-代码
最编程
2024-03-18 21:08:53
...
#输入数据
n=int(input())
Xli=list(map(int,input().split()))
Yli=list(map(int,input().split()))
Zli=list(map(int,input().split()))
#分别计算X-Y-Z/Y-Z-X/Z-X-Y并排序
newXli = sorted([Xli[i] - Yli[i] - Zli[i] for i in range(n)],reverse=True)
newYli = sorted([Yli[i] - Xli[i] - Zli[i] for i in range(n)],reverse=True)
newZli = sorted([Zli[i] - Xli[i] - Yli[i] for i in range(n)],reverse=True)
cnt=-1
#初始化每国士兵数量
x=y=z=0
#统计事件
for i in range(n):
x+=newXli[i]
y+=newYli[i]
z+=newZli[i]
if x>0 or y>0 or z>0:
cnt=max(cnt,i+1)
#输出结果
if cnt!=1:
print(cnt)
else:
print(-1)
推荐阅读