1008. Elevator (20)
来源:互联网 发布:统计年鉴数据不一致 编辑:程序博客网 时间:2024/06/17 06:58
1008. Elevator (20)
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.
For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled.
Input Specification:
Each input file contains one test case. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100.
Output Specification:
For each test case, print the total time on a single line.
Sample Input:3 2 3 1Sample Output:
41
/*************************************************************************> File Name: 1008.c> Author: YueBo> Mail: yuebowhu@163.com> Created Time: Sun 14 May 2017 08:15:38 AM CST ************************************************************************/#include<stdio.h>#define UPTIME 6#define DOWNTIME 4#define STAYTIME 5int main(){ int N, crnt_floor = 0, lst_floor = 0; int loopi; int diff; int sum = 0; scanf("%d", &N); for (loopi = 0; loopi < N; loopi++) { scanf("%d", &crnt_floor); diff = crnt_floor - lst_floor; if (diff > 0) sum += UPTIME * diff; else sum += DOWNTIME * diff * (-1); sum += STAYTIME; lst_floor = crnt_floor; } printf("%d\n", sum); return 0;}
- 1008. Elevator (20)
- 1008. Elevator (20)-PAT
- 【PAT】1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- PAT 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- PAT 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- Windows下搭建go语言开发环境 以及 开发IDE (附下载链接)
- 利用qemu搭建arm cortex a9开发环境以及gdb调试
- STM32自学——初识固件库(by Woody)
- 全卷积网络FCN的缺陷
- Linux上安装solr服务器(ik分词器下次奉上)
- 1008. Elevator (20)
- System Verilog视频学习笔记(11)- Functional converage
- Kafka(一): Kafka 入门
- android如何高效的在native处理bitmap图像
- System Verilog视频学习笔记(12)- VMM预览
- Openjudge 1.11 06:月度开销
- webrtc的socket接口
- 如何在本地myelipes中连接 云端mysql数据库
- [AtCoder AGC005 D][容斥][DP] ~K Perm Counting