Topic links: http://acm.hdu.edu.cn/showproblem.php?pid=3697
Because the election once every 5 minutes so you can enumerate 0-4 5-1000 can be added to obtain a 0-4 plus 55
Then is the topic that can be started when non-integer point that we enumerate 0.0001,1.0001,2.0001,3.0001,4.0001
So definitely better than enumeration 0-4 can choose to be more
so 我们for(i=0 to 4)
j = i to 1000 plus 5 per
A time period from the start if the <= j and end time> j would be chosen (assuming now because i is from 0 0.0001 actually representative of the start time so that time is 0, but may be selected on the end of the time must be> 0)
Code;
#include<bits/stdc++.h> using namespace std; struct node { int s,t; }a[305]; bool cmp(node x,node y) { if(x.t!=y.t)return x.t<y.t; return x.s<y.s; } int main() { int n,i,j; while(scanf("%d",&n),n) { for(i=0;i<n;i++) { scanf("%d%d",&a[i].s,&a[i].t); } sort(a,a+n,cmp); int maxx=0; for(i=0;i<=4;i++)//假设从0.001开始 即i=0 { int visit[305]; int ans=0; memset(visit,0,sizeof(visit)); for(j=i;j<=1000;j+=5) { for(int k=0 ; k <n-; k ++ ) { IF (Visit [k] == 0 && a [k] .s <&& j = a [k] .T> j) // this is a [k] can be equal to j .s (j i come from each addition. 5) { Visit [K] = . 1 ; ANS ++ ; BREAK ; } } } Maxx = max (Maxx, ANS); } COUT << Maxx << endl; } return 0 ; }