就是考试那题,50分,WA on 2,4,6,7,8,10,14,18,19,20
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define int long long
struct ex{
int a,b;
int fc;
}e[1001];
bool cmp(ex a,ex b){
return a.fc<b.fc;
}
signed main(){
int n,win=0,lost=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>e[i].a;
}
for(int i=0;i<n;i++){
cin>>e[i].b;
e[i].fc=e[i].b-e[i].a;
if(e[i].fc<0)win++;
else lost++;
}
if(win>lost){
cout<<0;
return 0;
}
sort(e,e+n,cmp);
int sum=0;
for(int i=0;i<n;i++){
if(e[i].fc>=0){
sum+=e[i].fc+1;
lost--;
win++;
}
if(win>lost)break;
}
cout<<sum;
return 0;
}