zoukankan      html  css  js  c++  java
  • Moving Tables

    Moving Tables

    Time Limit : 2000/1000ms(Java/Other)   Memory Limit : 65536/32768K (Java/Other)

    Total Submission(s) : 1   AcceptedSubmission(s) : 1

    Font:Times New Roman | Verdana | Georgia

    Font Size:← →

    Problem Description

    The famous ACM (Advanced Computer Maker) Company hasrented a floor of a building whose shape is in the following figure.



    The floor has 200 rooms each on the north side and south side along thecorridor. Recently the Company made a plan to reform its system. The reformincludes moving a lot of tables between rooms. Because the corridor is narrowand all the tables are big, only one table can pass through the corridor. Someplan is needed to make the moving efficient. The manager figured out thefollowing plan: Moving a table from a room to another room can be done within10 minutes. When moving a table from room i to room j, the part of the corridorbetween the front of room i and the front of room j is used. So, during each 10minutes, several moving between two rooms not sharing the same part of thecorridor will be done simultaneously. To make it clear the manager illustratedthe possible cases and impossible cases of simultaneous moving.



    For each room, at most one table will be either moved in or moved out. Now, themanager seeks out a method to minimize the time to move all the tables. Yourjob is to write a program to solve the manager’s problem.

    Input

    The inputconsists of T test cases. The number of test cases ) (T is given in the firstline of the input. Each test case begins with a line containing an integer N ,1<=N<=200 , that represents the number of tables to move. Each of thefollowing N lines contains two positive integers s and t, representing that atable is to move from room number s to room number t (each room number appearsat most once in the N lines). From the N+3-rd line, the remaining test casesare listed in the same manner as above.

    Output

    The outputshould contain the minimum time in minutes to complete the moving, one perline.

    Sample Input

    3

    4

    10 20

    30 40

    50 60

    70 80

    2

    1 3

    2 200

    3

    10 100

    20 80

    30 50

    Sample Output

    10

    20

    30

    Source

    Asia 2001, Taejon (South Korea) 

    //*************************
    //* 任务介绍:   移动桌子 *
    //* 作者: 何香           *
    //* 完成时间:2013.10.18  *
    //*************************
    #include<iostream>
    using namespace std;
    int main()
    {
    	int T,N,s[202],t[202];//从s房间move to  t房间
    	int i;
    	
    	cin>>T;
    	while(T--)
    	{
    		int min=0,move1=0;//计时
    		int temp=1;
    		
    		cin>>N;	//N需要搬几个桌子	
    		for(i=1;i<=N;++i)
    		{
    			cin>>s[i]>>t[i];
    			if(s[i]>t[i])
    			{
    				temp=s[i];
    				s[i]=t[i];
    				t[i]=temp;
    			}
    		}
    		
    		min=10;
    		
    		for(i=1;i<=N;++i)
    		{
    			if((s[i]%2==0)||(t[i]%2==0))
    			{
    				if(t[i]>=t[temp])
    				{
    					min=min;
    				}
    				else
    					min=min+10;
    				temp=i;
    			}
    			else
    				move1=move1+10;			
    		}
    		
    		
    		
    		cout<<min+move1<<endl;
    	}
    	
    }


  • 相关阅读:
    Linux系统备份与还原
    今后的日程安排(面试期间)
    我的下一份工作是什么样子呢?
    WebView 放大缩小
    Android EditText赋值后光标在后面
    android中捕捉menu按键的点击事件
    Android控件常用属性
    点击autocompletetextview时,如果没有输入时显示默认列表
    在Activity里怎样获得另一个xml布局文件的控件
    Android中的AutoCompleteTextView的使用
  • 原文地址:https://www.cnblogs.com/IT-hexiang/p/4084610.html
Copyright © 2011-2022 走看看