题目
代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5+10;
int a[N], b[N], c[N];
int w[4][N];
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 1; i <= n; i++)
cin >> b[i];
for(int i = 1; i <= n; i++)
cin >> c[i];
for(int i = 1; i <= n; i++)
{
int awin = a[i] - b[i] - c[i];
int bwin = b[i] - a[i] - c[i];
int cwin = c[i] - a[i] - b[i];
w[1][i] = awin;
w[2][i] = bwin;
w[3][i] = cwin;
}
int ans = 0;
for(int i = 1; i <= 3; i++)
{
sort(w[i] + 1, w[i] + n+1, greater<int>());
int cnt = 0, t = 1;
ll sum = 0;
for(int j = 1; j <= n; j++)
{
sum += w[i][j];
if(sum > 0) cnt++;
else break;
}
ans = max(ans, cnt);
}
cout << (ans ? ans : -1);
}