Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求数据!!!#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> using namespace std; int cmp(const void *a,const void *b) { return *(int *)b-*(int *)a; } int tian[1001]; int king[1001]; int main() { while(1) { int n; int i,j; cin>>n; if(!n) break; for(i=1;i<=n;i++) cin>>tian[i]; for(i=1;i<=n;i++) cin>>king[i]; qsort(tian+1,n,sizeof(tian[0]),cmp); qsort(king+1,n,sizeof(king[0]),cmp); int def=0,win=0; int l,r; i=l=1; j=r=n; while(l<=r) { if(tian[l]>king[i]) { win++; l++; i++; } else if(tian[l]<king[i]) { if(tian[r]<king[j]) { def++; r--; i++; } else{ def++; l++; i++; } } else { if(tian[r]<king[j]) { def++; r--; i++; } else { l++; r++; } } } cout<<(win-def)*200<<endl; } return 0; } 求数据。简单的贪心怎么总是WA? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator