码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 4883 TIANKENG’s restaurant

时间:2014-07-29 14:48:08      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:hdu 4883 bestcoder   sizeof   map   struct   

//暴搜
# 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;
}

















hdu 4883 TIANKENG’s restaurant,布布扣,bubuko.com

hdu 4883 TIANKENG’s restaurant

标签:hdu 4883 bestcoder   sizeof   map   struct   

原文地址:http://blog.csdn.net/lp_opai/article/details/38235213

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!