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<stdio.h> #define N 50000 void main() { int n,a[N],b[N],i,j,t,m=1; scanf("%d",&n); while(n) { for(i=0;i<n;i++) scanf("%d %d",&a[i],&b[i]); for(j=0;j<n-1;j++) for(i=0;i<n-1-j;i++) { if(a[i]>a[i+1]) { t=a[i]; a[i]=a[i+1]; a[i+1]=t; t=b[i]; b[i]=b[i+1]; b[i+1]=t; } if(a[i]==a[i+1]&&b[i]>b[i+1]) { t=a[i]; a[i]=a[i+1]; a[i+1]=t; t=b[i]; b[i]=b[i+1]; b[i+1]=t; } } for(i=n-1;i>=0;i--) { if(a[n-1]>=a[n-2]&&b[n-1]>=b[n-2]) break; if(a[i]==a[i-1]&&b[i]<b[i-1]) m++; if(a[i]>a[i-1]&&b[i]<b[i-1]) m++; } printf("%d\n",m); m=1; scanf("%d",&n); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator