首页 > 代码库 > hdu 4883 TIANKENG’s restaurant
hdu 4883 TIANKENG’s restaurant
//暴搜 # include <stdio.h> # include <algorithm> # include <string.h> using namespace std; struct node { int b; int e; int num; }; struct node a[10010]; int cmp(node a1,node a2) { return a1.b<a2.b; } int main() { int t,n,i,j,b1,b2,e1,e2,map[10010]; while(~scanf("%d",&t)) { while(t--) { scanf("%d",&n); memset(map,0,sizeof(map)); for(i=0;i<n;i++) { scanf("%d %d:%d %d:%d",&a[i].num,&b1,&b2,&e1,&e2); a[i].b=b1*60+b2; a[i].e=e1*60+e2; for(j=a[i].b;j<a[i].e;j++) map[j]+=a[i].num; } int max=0; for(i=0;i<=1440;i++) { if(map[i]>max) max=map[i]; } printf("%d\n",max); } } return 0; }
# include <stdio.h> # include <algorithm> # include <string.h> using namespace std; struct node { int b; int e; int num; }; struct node a[10010]; int cmp(node a1,node a2) { return a1.b<a2.b; } int main() { int t,n,i,j,sum,numsum,b1,b2,e1,e2,numsum1; int vis[10010]; scanf("%d",&t); while(t--) { scanf("%d",&n); memset(vis,0,sizeof(vis)); for(i=0;i<n;i++) { scanf("%d %d:%d %d:%d",&a[i].num,&b1,&b2,&e1,&e2); a[i].b=b1*60+b2; a[i].e=e1*60+e2; vis[a[i].b]+=a[i].num; vis[a[i].e]-=a[i].num; } sort(a,a+n,cmp); numsum=a[0].num; for(i=1;i<=60*24;i++) { vis[i]+=vis[i-1]; if(numsum<vis[i]) numsum=vis[i]; } printf("%d\n",numsum); } return 0; }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。