2017年河南省ACM省赛 Problem H: Intelligent Parking Building
2017-06-07 20:20
357 查看
问题 H: Intelligent Parking Building
时间限制: 1 Sec 内存限制: 128 MB题目描述
There is a new revolution in the parking lot business: the parking building. The concept is simple: you drive your car into the elevator at the entrance of the building, and the elevator and conveyor belts dragthe car to an empty parking spot, where the car remains until you pick it up. When you return, the elevator and conveyor belts move your car back to the entrance and you’re done.
The layout of the building is simple. There is one central elevator that transports the cars between the different floors. On each floor there is one giant circular conveyor belt on which the cars stand. This belt
can move in clockwise and counterclockwise direction. When the elevator arrives on a floor, it becomes part of the belt so that cars can move through it.
At the end of the day the building is usually packed with cars and a lot of people come to pick them up. Customers are processed in a first come first serve order: the elevator is moved to the floor of the first
car, the conveyor belt moves the car on the elevator, the elevator is moved down again, and so on. We like to know how long it takes before the last customer gets his car. Moving the elevator one floor up- or downwards takes 10 seconds and moving the conveyor
belt one position in either direction takes 5 seconds.
输入
On the first line one positive number: the number of testcases, at most 30. Each test case specifies:One line with two integers h and l with 1 ≤ h ≤ 50 and 2 ≤ l ≤ 50: the height of the parking tower and the length of the conveyor belts.
h lines with l integers: the initial placement of the cars. The jth number on the ith line describes the jth position on the ith floor. This number is −1 if the position
is empty, and r if the position is occupied by the rth car to pick up. The positive numbers form a consecutive sequence from 1 to the number of cars. The entrance is on the first floor and the elevator (which is initially empty) is in the
first position. There is at least one car in the parking tower.
输出
For each test case generate a single line containing a single integer that is the number of seconds before the last customer is served.样例输入
3 1 5 1 -1 -1 -1 2 1 5 2 -1 -1 -1 1 3 6 -1 5 6 -1 -1 3 -1 -1 7 -1 2 9 -1 10 4 1 8 -1
样例输出
5 10 320
提示
这道题其实很简单,只不过大部分人是因为没正确理解题意,题意:一个地下停车场,高h层,每层l个车位,-1表示该位置为空,正整数表示运出车辆的序号,现在需要按照序号运出车辆,运出过程:电梯初始在1层,每上下移动一层需要10秒,每层有一个转盘,车位均在转盘上,可以顺时针转,也可以逆时针转,初始时电梯对应转盘的第一个位置,每次转盘转动之后不再回到初始位置,每转动一个车位需要5秒。每次将需要运出的车转到电梯的位置后还需要将电梯返回1层。现在需要计算最小的将车全部运出的时间。代码
#include <algorithm> #include <iostream> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cstdlib> #include <cstring> #include <cstdio> #include <cmath> using namespace std; int a[55][55]; int main() { int T; scanf("%d",&T); while(T--) { int h,l,sum=0,maxn=-1,num=1,p[55]; for(int i=0;i<55;i++) p[i]=1;///存放每层电梯对应的转盘位置,初始都为转盘的第一个位置 scanf("%d %d",&h,&l); for(int i=1;i<=h;i++) { for(int j=1;j<=l;j++) { scanf("%d",&a[i][j]); maxn=max(maxn,a[i][j]);///记录最大的序号,用来后面跳出循环 } } for(int i=1;i<=h;i++) { for(int j=1;j<=l;j++) { if(a[i][j]==num) { sum+=20*(i-1);///每层需要10秒返回需要同样的时间,所以直接层数的差值乘以20 sum+=5*min(abs(p[i]-j),l-(abs(p[i]-j)));///判断顺时针转还是逆时针转动转盘次数最少,然后最少次数乘以5 p[i]=j;///把第i层的电梯对应的转盘位置变为j; num++;///序号增加 i=1; j=0; } if(num>maxn)break;///如果全部车都运出则跳出循环 } if(num>maxn)break;///如果全部车都运出则跳出循环 } printf("%d\n",sum); } }
相关文章推荐
- 2017年河南省ACM省赛 Problem C: 最小密匙
- 2017年河南省ACM省赛 Problem D: 年终奖金
- 2017年河南省ACM省赛 Problem G: Plumbing the depth of lake
- 河南省第十届ACM省赛题目:问题 H: Intelligent Parking Building
- 2017年河南省ACM省赛 Problem A: 谍报分析
- 2017年河南省ACM省赛 Problem C: 最小秘钥
- H Intelligent Parking Building 河南第十届ACM真题 【模拟】
- 2017年河南省ACM省赛 Problem F: Binary to Prime
- 第十届省赛-H-Intelligent Parking Building
- 第八届河南省ACM省赛 - G - Interference Signal
- fireworks 2017年山东省ACM省赛C题 SDUT 3895 (逆元求组合数)
- 2017年广东ACM省赛 I题 解题报告
- [河南省ACM省赛-第五届] 最强DE 战斗力 (nyoj 541)
- 2017年第十届河南省ACM省赛 B题情报传递
- [河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)
- NYOJ 1274 河南省第九届ACM省赛 C题
- [河南省ACM省赛-第四届] 走迷宫 (nyoj 306)
- Intelligent Parking Building
- 引水工程 河南省ACM2015年省赛D 题(最小生成树)
- [河南省ACM省赛-第三届] 房间安排 (nyoj 168)