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

测试数据太弱了,我这样的写的二分也都AC了

Posted by bjss222 at 2007-07-21 16:51:53 on Problem 2456
int main(){
	int lt, rt, mid, tag, i;
	while(scanf("%d %d", &n, &c)!=EOF){
		for(i=0; i<n; i++) scanf("%d", &a[i]);
                  sort(a,a+n); 
                  lt=a[0]; rt=a[n-1];    
		while(lt<=rt){   
			mid=(lt+rt)/2;  
                           if(check(mid)) lt=mid+1,tag=mid;
			else           rt=mid-1;
		}
                  printf("%d\n",tag);
	}
	return 0;
}
我二分时取的lt=a[0]; rt=a[n-1];
若数据为
3 2  
100 
101
102
时结果肯定错,但竟然AC了

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