//三国游戏:贪心#include<bits/stdc++.h>#defineintlonglong#defineendl'\n'#definedeb(x) cout << #x <<" = "<< x <<'\n';#defineINF0x3f3f3f3fusingnamespace std;int n;intcal_ans(vector<int>&a, vector<int>&b, vector<int>&c){
vector<int>tmp(n);int sum =0;for(int i =0; i < n; i ++)
tmp[i]= a[i]-(b[i]+ c[i]);sort(tmp.begin(), tmp.end());int cnt =0;for(int i = n -1; i >=0; i --){
if(sum + tmp[i]>0){
sum += tmp[i];
cnt ++;}elsebreak;}return cnt;}voidsolve(){
cin >> n;
vector<int>a(n),b(n),c(n);for(int i =0; i < n; i ++)
cin >> a[i];for(int i =0; i < n; i ++)
cin >> b[i];for(int i =0; i < n; i ++)
cin >> c[i];int ans =0;
ans =cal_ans(a, b, c);//x赢
ans =max(ans,cal_ans(b, a, c));//y赢
ans =max(ans,cal_ans(c, a, b));//z赢if(ans)
cout << ans << endl;else
cout <<-1<< endl;}signedmain(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);int t;
t =1;//cin >> t;while(t--)solve();}
文章评论