ZOJ Problem Set - 2397 Tian Ji -- The Horse Racing

#include
#include
#include
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int a[2000],b[2000],n;
int main(){
    while (cin>>n,n){
        REP(i,n)cin>>a[i];
        REP(i,n)cin>>b[i];
        sort(a,a+n);
        sort(b,b+n);
        int ha=0,ta=n-1,hb=0,tb=n-1,ans=0;
        REP(i,n){
            if (a[ha]>b[hb])ans++,ha++,hb++;
            else if (a[ta]>b[tb])ans++,ta--,tb--;
            else ans-=(a[ha]!=b[tb]),ha++,tb--;
        }
        cout<200<<endl;
    }
    return 0;
}

#define 用起来

你可能感兴趣的:(ZOJ Problem Set - 2397 Tian Ji -- The Horse Racing)