题目
思路
全网建议看这篇,看懂了再去看其他的就明白为啥这么说了。。。
田忌赛马(贪心) - Nothing9826的博客 - CSDN博客
代码
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
ll n;
ll a[1020],b[1020];
int cmp(ll x,ll y){
return x>y;
}
ll ans=0;
int main(){
while(scanf("%lld",&n)==1&&n){
ans=0;
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
for(int i=1;i<=n;i++){
scanf("%lld",&b[i]);
}
sort(a+1,a+1+n,cmp);
sort(b+1,b+1+n,cmp);
int poi=1;
int i=1,j=n,k=1,l=n;
for(int s=1;s<=n;s++){
if(a[i]>b[k]){
i++,k++;
ans++;
}
else if(a[j]>b[l]){
ans++;
j--,l--;
}
else{
if(a[j]<b[k]) ans--;
j--,k++;
}
}
cout<<ans*200<<endl;
}
return 0;
}