• Flo's Restaurant[HDU1103]


    Flo's Restaurant

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 932    Accepted Submission(s): 285

     

    Problem Description
    Sick and tired of pushing paper in the dreary bleary-eyed world of finance, Flo ditched her desk job and built her own restaurant.

     

    In the small restaurant, there are several two-seat tables, four-seat tables and six-seat tables. A single diner or a group of two diners should be arranged to a two-seat table, a group of three or four diners should be arranged to a four-seat table, and a group of five or six diners should be arranged to a six-seat table.

     

    Flo’s restaurant serves delicious food, and many people like to eat here. Every day when lunch time comes, the restaurant is usually full of diners. If there is no suitable table for a new coming group of diners, they have to wait until some suitable table is free and there isn’t an earlier arrival group waiting for the same kind of tables. Kind Flo will tell them how long they will get their seat, and if it’s longer than half an hour, they will leave for another restaurant.

     

    Now given the list of coming diners in a day, please calculate how many diners take their food in Flo’s restaurant. You may assume it takes half an hour for every diner from taking a seat to leaving the restaurant.

     

     

     

    Input
    There are several test cases. The first line of each case contains there positive integers separated by blanks, A, B and C (A, B, C >0, A + B + C <= 100), which are the number of two-seat tables, the number of four-seat tables and the number of six-seat tables respectively. From the second line, there is a list of coming groups of diners, each line of which contains two integers, T and N (0 < N <= 6), representing the arrival time and the number of diners of each group. The arrival time T is denoted by HH:MM, and fixed between 08:00 and 22:00 (the restaurant closes at 23:00). The list is sorted by the arrival time of each group in an ascending order, and you may assume that no groups arrive at the same time. Each test case is ended by a line of “#”.

     

    A test case with A = B = C = 0 ends the input, and should not be processed.

     

     

     

    Output
    For each test case, you should output an integer, the total number of diners who take their food in Flo’s restaurant, in a separated line.

     

     

     

    Sample Input
    1 1 1
    10:40 1
    10:50 2
    11:00 4
    #
    1 1 1
    10:40 1
    10:50 2
    11:00 2
    #
    1 2 1
    10:30 1
    10:40 3
    10:50 2
    11:00 1
    11:20 5
    #
    0 0 0
     

     

    Sample Output
    7
    3
    12
     

     

    Author
    Alcyone
     

     

    Recommend
    Eddy

    让排队的时间尽量短

    #include<stdio.h>
    #include<string.h>
    int s[4][125];
    int main()
    {
    	while (scanf("%d%d%d",s[1],s[2],s[3])!=EOF)
    	{
    		if (s[1][0]+s[2][0]+s[3][0]==0) return 0;
    		memset(&s[1][1],0,sizeof(s[1])-4);
    		memset(&s[2][1],0,sizeof(s[2])-4);
    		memset(&s[3][1],0,sizeof(s[3])-4);
    		int ans=0,H,M,N,i;
    		char ch;
    		getchar();
    		ch=getchar();
    		while (ch!='#')
    		{
    			scanf("%d:%d%d",&H,&M,&N);
    			getchar();
    			H+=(ch-48)*10;
    			ch=getchar();
    			int x=(N-1)/2+1,T=H*60+M,v,Min;
    			bool flag=false;
    			for (i=1;i<=s[x][0];i++)
    			{
    				if (T>=s[x][i])
    				{
    					s[x][i]=T+30;
    					flag=true;
    					ans+=N;
    					break;
    				}
    			}
    			if (!flag)
    			{
    				Min=2000;
    				for (i=1;i<=s[x][0];i++)
    					if (s[x][i]-T<Min)
    					{
    						Min=s[x][i]-T;
    						v=i;
    					}
    				if (Min<=30)
    				{
    					ans+=N;
    					s[x][v]+=30;
    				}
    			}
    		}
    		printf("%d
    ",ans);
    	}
    	return 0;
    }

     

  • 相关阅读:
    PHP面向对象魔术方法基本了解
    PHP面向对象访问修饰符的基本了解
    php析构函数小结
    php构造方法(函数)基础
    php面向对象成员方法(函数)练习
    php面向对象的初认识
    用JS把数组内的日期转换为星期
    JavaScript事件(随笔)
    Spring框架的核心功能之AOP技术
    Spring框架 IOC注解
  • 原文地址:https://www.cnblogs.com/dramstadt/p/3259871.html
Copyright © 2020-2023  润新知