ZOJ Problem Set - 2397 Tian Ji -- The Horse Racing
#include<iostream> #include<cmath> #include<algorithm> #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<<ans*200<<endl; } return 0; }
#define 用起来