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

差46MS超时水过!(附代码)

Posted by CCUT2015_wangzhao at 2015-02-03 16:13:00 on Problem 2376
#include<cstdio>


const int maxn = 25000 + 20;
struct cow{
	int start,end;
}c[maxn];


int main()
{
	//freopen("input.txt","r",stdin);
	int N,T,i;
	while(scanf("%d%d",&N,&T) == 2)
	{
		for(i = 0; i < N; i++)
			scanf("%d%d",&c[i].start,&c[i].end);
		int start = 0;//这里start end 初始化一定要一样。。。否则就坑了,我WA了好多次!
		int end = 0;
		int sum = 0;
		while(start < T)
		{
			for(i = 0; i < N; i++)
			{
				if(c[i].start <= start + 1 && c[i].end > end)
					end = c[i].end;
			}
			
			if(end == start )
			{
				sum = -1;
				break;
			}
			start = end;
			sum++;
		}
		printf("%d\n",sum);
	}
	return 0;
}




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