AC代码:
#include <iostream> #include <cstdio> #include <algorithm> #define Max 1010 using namespace std; bool compare(int a,int b) { return a>b; } long long int ti[Max]; long long int k[Max]; int main(void) { long long money; freopen("in.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF&&n) { for(int i=1;i<=n;i++) scanf("%d",&ti[i]); for(int i=1;i<=n;i++) scanf("%d",&k[i]); sort(ti+1,ti+1+n,compare); sort(k+1,k+1+n,compare); int m=n,count=0,timin=n,timax=1,kmin=n,kmax=1; while(m) { if(ti[timin]>k[kmin]) { count++; m--; timin--; kmin--; } else if(ti[timin]<k[kmin]) { count--; m--; timin--; kmax++; } else if(ti[timax]>k[kmax]) { count++; m--; timax++; kmax++; } else if(ti[timax]<k[kmax]) { count--; m--; kmax++; timin--; } else if(ti[timin]==k[kmax]) { break; } else if(ti[timin]<k[kmax]) { m--; count--; timin--; kmax++; } } money=200*count; printf("%lld ",money); } fclose(stdin); return 0; }