H Intelligent Parking Building 河南第十届ACM真题 【模拟】
来源:互联网 发布:网络短信平台软件 编辑:程序博客网 时间:2024/05/20 11:22
/*
有一个停车楼,停车楼里的车需要全部开出去,标号为-1的位置为空,其他的数字为汽车,汽车出库必须要按照数字从小到大的顺序,
停车楼出口为第一层第一个 位置,其中电梯在每一行的第一列, 每一行是一个环形传送带,每移动一格耗费5分钟,每移动一层消耗10分钟,
电梯每上楼接车,到达每一层接车,然后下去从开头出口出去。 问你最少耗费多长时间所有的车都可以出去。
*/
题意好难,思路不难。
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
#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>using namespace std;int map[55][55];struct Node{int x;int y;}edge[50*52];int main(){int T;scanf("%d",&T);while(T--){int i,j,h,l;int sum = 0;int count = 0;scanf("%d%d",&h,&l);for(i=1;i<=h;i++){map[i][0] = 1;for(j=1;j<=l;j++){scanf("%d",&map[i][j]);if(map[i][j] != -1){edge[map[i][j]].x = i;edge[map[i][j]].y = j;if(map[i][j] > count){count = map[i][j];}}}}for(i=1;i<=count;i++)//汽车从小到大出库 {int x = edge[i].x;int y = edge[i].y;sum += ((x - 1)* 10 * 2);//电梯 上楼接 再回去从出口把车送出去 ,所以结果*2 int res = min(abs(y - map[x][0]),l - abs(y - map[x][0]));//在同行中 找距离左右两边最近的那个。 sum += res * 5;map[x][0] = y;}printf("%d\n",sum);}return 0;}
0 0
- H Intelligent Parking Building 河南第十届ACM真题 【模拟】
- 河南省第十届ACM省赛题目:问题 H: Intelligent Parking Building
- 第十届省赛-H-Intelligent Parking Building
- 2017年河南省ACM省赛 Problem H: Intelligent Parking Building
- 问题 H: Intelligent Parking Building
- C 最小密钥 河南第十届ACM真题 【模拟】
- F Binary to Prime 河南第十届ACM真题 【模拟】
- Intelligent Parking Building
- Intelligent Parking Building
- B 情报传递 河南第十届ACM真题 【图】
- D 年终奖金 河南第十届ACM真题 【dp】
- A 谍报分析 河南第十届ACM真题 【字符串处理】
- G Plumbing the depth of lake 河南第十届ACM真题 【搜索】
- 第十届河南 ACM 省赛纪事
- 河南第十届ACM省赛-E-八纵八横
- 河南第十届ACM省赛-D-年终奖金
- 河南第十届ACM省赛-C-最小密钥
- 河南第十届ACM省赛-I-Transmit information
- BZOJ1085 骑士精神
- web框架之利用python的反射模拟小web框架(一)
- Java中Synchronized的用法
- [Maven]私服Nexus搭建
- servlet的生命周期和工作原理
- H Intelligent Parking Building 河南第十届ACM真题 【模拟】
- linux学习的几个网站
- Git Book读书笔记--git储藏和清理&&搜索
- 多文件中函数的重复定义
- 程序员面试金典——字符串排列______
- 垂直居中的几种方法
- 验证码只能为大写输入
- 2.输入一个链表,从尾到头打印链表每个节点的值
- 为什么 ++[[]][+[]]+[+[]] = 10?