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 |
why wa?牛人帮忙看看...#include<iostream> using namespace std; int partition(int *b,int low,int high); void quicksort(int *a,int i,int j); int d[10005],c[10005]; int main() { int n,i,min,nub; cin>>n; while(n) { for(i=0;i<n;i++) cin>>d[i]>>c[i]; quicksort(d,0,n-1); min=c[0];nub=1; for(i=1;i<n;i++) if(c[i]<min) min=c[i],nub++; // for(i=0;i<n;i++) // cout<<d[i]<<" "; // cout<<endl; // for(i=0;i<n;i++) // cout<<c[i]<<" "; // cout<<endl; cout<<nub<<endl; cin>>n; } return 0; } int partition(int *b,int low,int high) { int x,l=low,h=high,y; x=b[low]; y=c[l]; while(l!=h) { while(l<h&&(b[h]>x||b[h]==x&&c[h]>y)) --h; b[l]=b[h];c[l]=c[h]; while(l<h&&(b[l]<=x||b[h]==x&&c[h]<y)) ++l; b[h]=b[l];c[h]=c[l]; } b[l]=x;c[l]=y; return l; } void quicksort(int *a,int i,int j) { if(i<j) { int pivotpos=partition(a,i,j); quicksort(a,i,pivotpos-1); quicksort(a,pivotpos+1,j); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator