Moving Tables POJ - 1083

Topic Link to
this floor a total of 400 rooms, 200 rooms on each side. Recently, the company would like to make some adjustments, including moving a lot of room between tables. Because a very narrow corridor, a large table, only one table through the corridor, it is necessary to specify a plan to move the table and more efficient. The tables move from one room to another room can be completed within 10 minutes, when the table is moved from room to room i j, i j room from the room to the corridor section is occupied (closed interval). Within 10 minutes, move multiple tables if you do not share the corridor, you can be at the same time. Input of T test, the first test input line number T, followed sequentially input data for each test case. The first input line of each test case needs to move the table number N, 1 <= N <= 200, the next line of input two integers N s and t, s represents the table moves from room to room t. It occurs once at most in each room N input lines. Output takes a minimum of time.
. 3
. 4
10 20 is
30 40
50 60
70 80
2
. 1. 3
2 200 is
. 3
10 100
20 is 80
30 50
the Sample the Output
10
20 is
30

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int t,n,temp,s,e;
    cin>>t;
    while(t--)
    {
        int a[205]={0},m=0;
        cin>>n;
        while(n--)
        {
            cin>>s>>e;
            if(s>e)
            {
                temp=s;
                s=e;
                e=temp;
            }
            for(int i=(s-1)/2;i<=(e-1)/2;i++)
            {
                a[i]++;
            }
        }
        for(int i=0;i<205;i++)
        {
            if(m<a[i])
                m=a[i];
        }
        cout<<10*m<<endl;
    }
    return 0;
}

Published 81 original articles · won praise 3 · Views 2754

Guess you like

Origin blog.csdn.net/weixin_44641254/article/details/104739469