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

本题的数据确实很弱,只需要直接模拟就行了,一次AC 0ms飘过... 贴代码!!!

Posted by datacw at 2011-09-24 16:45:55 on Problem 2705
In Reply To:这题的数据好弱.只要设计一个变量记录总长就可以了 Posted by:zsasuke at 2009-05-01 01:03:13
#include <iostream>
using namespace std;
int main()
{
	int a[105];   //书架上书目的编号
	int b[105];     //书架上对应书目的宽度
	int s,w,i,j,k,len;
	char ch;
	int count=0;
	while(cin>>s && s!=-1)   //s为书架的宽度
	{
		count++;
		i=0;   //书架上书的数目
		len=0; //当前数目的长度
        while(cin>>ch)
		{
          if(ch=='R')
		  {
			  cin>>w;
			  for(j=0;j<i;j++)
				  if(w==a[j]) break;
              if(j<i)
			  {
                    len-=b[j];
                  for(k=j;k<i-1;k++)
				  {
					  a[k]=a[k+1];
					  b[k]=b[k+1];
				  }
				  i--;
			  }
		  }
		  else if(ch=='A') 
		  {
			  cin>>k>>w;
                while(w+len>s)
				{					
					len-=b[i-1];
						i--;
				}
            for(j=i-1;j>=0;j--)
			{
				a[j+1]=a[j];
				b[j+1]=b[j];
			}
			a[0]=k;b[0]=w;
			i++;
			len+=w;
		  }
		  else break;
		}
		cout<<"PROBLEM "<<count<<':';
		for(j=0;j<i;j++)
			cout<<' '<<a[j];
		cout<<endl;
	}
	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