hdu 1050 Moving Tables
来源:互联网 发布:java初学者项目案例 编辑:程序博客网 时间:2024/05/21 18:46
题目地址链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050
Moving Tables
Problem Description
The famous ACM (Advanced Computer Maker) Company has rented 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 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.
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.
Input
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.
Output
The output should contain the minimum time in minutes to complete the moving, one per line.
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
102030
代码:
#include<stdio.h>int main (){ int f[402];int i,j,m,n,a,x,y,max,t; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) { scanf("%d",&m);int f[402]={0};max=0; for(j=0;j<m;j++) { scanf("%d%d",&x,&y);if(x>y){t=x;x=y;y=t;} for(a=x;a<=y;a++) { f[a]++; } if(x%2==0) f[x-1]++; if(y%2!=0) f[y+1]++; } for(j=0;j<401;j++) { if(f[j]>max){max=f[j];} } printf("%d\n",max*10); } } return 0;}
- HDU 1050 Moving Tables
- hdu 1050 moving tables
- HDU-1050 Moving Tables
- hdu-1050-Moving Tables
- HDU 1050 Moving Tables
- HDU 1050 Moving Tables
- hdu 1050 moving tables
- hdu 1050 Moving Tables
- hdu 1050 Moving Tables
- hdu 1050 Moving Tables
- HDU (1050) Moving Tables
- HDU--1050 -- Moving Tables
- hdu 1050 Moving Tables
- hdu 1050 Moving Tables
- HDU 1050 Moving Tables
- hdu-1050 Moving Tables
- hdu 1050 Moving Tables
- HDU 1050 Moving tables
- 学习笔记——C#的StringBuilder
- UITableView 右边索引第一个出现空白情况的解决办法
- [2013 Codejam Round 1B Problem B] 呵呵。。。
- javascript中如何延迟执行一个方法
- 如何在遍历时删除List中的元素
- hdu 1050 Moving Tables
- 舵机打表生成器
- 如何正确遍历删除List中的元素,你会吗?
- python中的字典
- 初探Tomcat源码 (1) —— Http请求和响应
- linux 0.11 在 bochs中的调试问题 - 解决缺页中断(page_fault)问题
- 用普通类接受表单数据
- Python源码剖析读书笔记
- 初探Tomcat源码 (2) —— Socket