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

Re:my analysis

Posted by chenqiong at 2007-07-25 16:12:28 on Problem 3282
In Reply To:Re:my analysis Posted by:chenqiong at 2007-07-25 10:56:54
我们没有排序呀
#include<iostream>
using namespace std;
double a[100000],b[100000],l,ct;
int main()
{
	int w,n,i,j,sum,c,t;
	char s[20];
	scanf("%d",&w);
	while((w--)!=0)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		sum=0;
		scanf("%lf%d",&l,&n);
		for(t=0,i=0,j=0;t<n;t++)
		{
			scanf("%d",&c);
			scanf("%s",s);
			if(strcmp(s,"left")==0)	
				a[i++]=c/100.0;
			else 
				b[j++]=c/100.0;
		}
		for(t=0,c=0;t<i;)
		{
			if(t<i-1&&a[t]+a[t+1]<l)
			{
				for(ct=a[t],t=t+1;t<i;t++)
				{
					ct=ct+a[t];
					if(ct>l)break;
				}
			}
			else t++;
			c++;
		}
		i=c;
		for(t=0,c=0;t<j;)
		{
			if(t<j-1&&b[t]+b[t+1]<l)
			{
				for(ct=b[t],t=t+1;t<j;t++)
				{
					ct=ct+a[t];
					if(ct>l)break;
				}
			}
			else t++;
			c++;
		}
		j=c;
		if(i>j)sum=2*i-1;
		else  sum=2*j;
		printf("%d\n",sum);
	}
	return 0;
}

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