标签:des blog io ar os sp for div on
Description
Input
Output
Sample Input
Sample Output
#include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> #include <cstring> using namespace std; const int maxn=550; struct node { int ai,bi; } task[maxn]; int nn; bool mark[maxn]; bool cmp(node A, node B) { if(A.bi==B.bi) return A.ai<B.ai; return A.bi<B.bi; } int solve(int ss) { int ans=0; memset(mark,0,sizeof(mark)); for(int i=ss;i<=task[nn-1].bi;i+=5){ for(int j=0;j<nn;j++){ if(mark[j]) continue; if(i>=task[j].ai&&i<task[j].bi){ ans++; mark[j]=1; break; } } } return ans; } int main() { int ans; while(scanf("%d",&nn),nn!=0){ for(int i=0;i<nn;i++) scanf("%d%d",&task[i].ai,&task[i].bi); sort(task,task+nn,cmp); ans=0; for(int i=0;i<5;i++) ans=max(ans,solve(i)); printf("%d\n",ans); } }
hdu 3697 10 福州 现场 H - Selecting courses
标签:des blog io ar os sp for div on
原文地址:http://www.cnblogs.com/xuesu/p/4087979.html