<h1>Problem A </h1><h5>Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)</h5><h5>Total Submission(s) : 349 Accepted Submission(s) : 46</h5><div class="panel_title" align="left">Problem Description</div><div class="panel_content">The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.
<center><img style="MAX-WIDTH: 100%" src="http://acm.hdu.edu.cn/data/images/1050-1.gif" alt="" /></center>
The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes moving a lot of tables between rooms. Because the corridor is narrow and all the tables are big, only one table can pass through the corridor. Some plan is needed to make the moving efficient. The manager figured out the following plan: Moving a table from a room to another room can be done within 10 minutes. When moving a table from room i to room j, the part of the corridor between the front of room i and the front of room j is used. So, during each 10 minutes, several moving between two rooms not sharing the same part of the corridor will be done simultaneously. To make it clear the manager illustrated the possible cases and impossible cases of simultaneous moving.
<center><img style="MAX-WIDTH: 100%" src="http://acm.hdu.edu.cn/data/images/1050-2.gif" alt="" /></center>
For each room, at most one table will be either moved in or moved out. Now, the manager seeks out a method to minimize the time to move all the tables. Your job is to write a program to solve the manager’s problem.
</div><div class="panel_bottom"> </div>
<div class="panel_title" align="left">Input</div><div class="panel_content">The input consists of T test cases. The number of test cases ) (T is given in the first line 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 the following N lines contains two positive integers s and t, representing that a table is to move from room number s to room number t (each room number appears at most once in the N lines). From the N+3-rd line, the remaining test cases are listed in the same manner as above. </div><div class="panel_bottom"> </div>
<div class="panel_title" align="left">Output</div><div class="panel_content">The output should contain the minimum time in minutes to complete the moving, one per line. </div><div class="panel_bottom"> </div>
<div class="panel_title" align="left">Sample Input</div><div class="panel_content"><pre><div style="FONT-FAMILY: Courier New,Courier,monospace">3
4
10 20
30 40
50 60
70 80
2
1 3
2 200
3
10 100
20 80
30 50
</div>
Sample Output
10 20 30
木板运送的问题
设立数组
求重叠部分
重叠加一
知道最后求数组中最大的数。
#include<iostream>
#include<string.h>
#include<set>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<math.h>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
using namespace std;
struct hh
{
int k;
int l;
};
bool comp(const hh &A,const hh &B)
{
if(A.k!=B.k)
return A.l<B.l;
else
return A.k<B.k;
}
int main()
{
int n;
cin>>n;
int i;
vector<hh> s;
hh w;
int t,x1,x2,x3;
for(i=1;i<=n;i++)
{ cin>>t;
for( x1=1;x1<=t;x1++)
{
cin>>w.k;
cin>>w.l;
if(w.k>w.l)
{
swap(w.k,w.l);
}
s.push_back(w);
}
int a[200];
memset(a,0,sizeof(a));
int e;
int oo;
for(e=0;e<t;e++)
{
for(oo=(s[e].k-1)/2;oo<=(s[e].l-1)/2;oo++)
{
a[oo]++;
}
}
int mix;
mix=a[0];
int ss;
for(ss=0;ss<200;ss++)
{
if(mix<a[ss])
mix=a[ss];
}
cout<<mix*10<<endl;
s.clear();
}
return 0;
}