| ||||||||||
| 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 | |||||||||
差46MS超时水过!(附代码)#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator