Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA 请大神帮忙看看怎么一直WA,数据试了很多

Posted by ayin at 2013-04-08 16:36:13 on Problem 3636
#include "stdio.h"
#include "stdlib.h"
int cmp(const void *m, const void *n){
	int *a=(int*)m,*b=(int*)n;
	return (*a==*b)?(*(a+1)<*(b+1)):(*a>*b);
}
int main()
{
	int data[20005][2];
	int t,m;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&m);
		for(int i=0;i<m;i++)scanf("%d %d",&data[i][0],&data[i][1]);
		qsort(data,m,sizeof(int)*2,cmp);
		int j=0;
		for(int i=1;i<m;i++){
			if(data[i][1]<=data[j][1])data[++j][1]=data[i][1];
			else {
				int s=0,e=j,mid;
				while(s<=e){
					mid = (s+e)/2;
					if(data[mid][1]<data[i][1])e = mid-1; 
					else s = mid+1;
				}
				data[s][1]=data[i][1];
			}
		}
		printf("%d\n",j+1);
	}
	system("pause");
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator