Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大牛们帮忙看看代码把 谢了!!!!

Posted by miaomiaomiaomiao at 2006-08-16 21:45:29 on Problem 2424
#include <cstdlib>
#include <stdio.h>
#include <deque>

using std::deque;

int main(int argc, char *argv[])
{
	int total;
	int a,b,c;
	int left[4];
	char ch[10];
	int table;
	int time,endtime;
	int person;
	while(scanf("%d%d%d",&a,&b,&c))
	{
		if(a==0&&b==0&&c==0)
		break;
		deque<int> times[4];
		total=0;
		left[1]=a;
		left[2]=b;
		left[3]=c;
		while(scanf("%s",ch))
		{
			if(ch[0]=='#')
			break;
			scanf("%d",&person);
			time=((int(ch[0])-48)*10+int(ch[1])-48)*60+(int(ch[3])-48)*10+int(ch[4])-48;
			endtime=time+30;
			table=(person+1)/2;
			bool boo=1;
			if(left[table]>0)
			{
				total+=person;
				times[table].push_back(endtime);
				left[table]--;
				continue;
			}
			while(!times[table].empty())
			{
				int tmp=times[table].front();
				if(tmp<time)
				{
					left[table]++;
					times[table].pop_front();
					if(boo)
					{
						total+=person;
						times[table].push_back(time+30);
						left[table]++;
						boo=0;
					}
				}
				else if(tmp>=time&&tmp<=time+30&&boo)
				{
					times[table].pop_front();
					times[table].push_back(tmp+30);
					total+=person;
					boo=0;
				}
				else
				break;
			}
		}
		printf("%d\n",total);
	}
    return EXIT_SUCCESS;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator