rt,求调,玄关
#include <bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int a[N];
int b[N];
int c[N];
int main(){
int n,sum=0,win=0,lose=0,pin=0;
cin>>n;
for(int i=1;i<=n;i++) c[i]=1e9;
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++){
if(a[i]<=b[i]){
if(a[i]<b[i]){
lose++;
c[i]=b[i]-a[i]+1;
}
else{
pin+=1;
}
}
else{
win++;
}
}
int ii;
sort(c+1,c+n+1);
if(win==lose&&pin>0) sum=1;
else if(win==lose&&pin==0){
ii=1;
while(win<=lose){
sum+=c[ii];
ii++;
}
}
else if(win<lose&&pin>0){
ii=1;
while(pin>0||win<=lose){
sum+=1;
win+=1;
pin--;
}
if(pin==0&&win<=lose){
while(win<=lose){
sum+=c[ii];
ii++;
}
}
}
else{
ii=1;
while(win<=lose){
sum+=c[ii];
ii++;
}
}
cout<<sum;
}