参考代码:
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) #将每个事件对三个国家的影响当作贡献值,做预处理 contribution = [[] for _ in range(n)] for i in range(n): contribution[0].append(a[i] - b[i] - c[i]) contribution[1].append(b[i] - a[i] - c[i]) contribution[2].append(c[i] - a[i] - b[i]) #排序是为了最优选择 for i in range(3): contribution[i] = sorted(contribution[i], reverse=True) res = -1 sum_a, sum_b, sum_c = 0, 0, 0 for i in range(n): sum_a += contribution[0][i] sum_b += contribution[1][i] sum_c += contribution[2][i] if sum_a > 0 or sum_b > 0 or sum_c > 0: res = i + 1 print(res)
0.0分
0 人评分