Aoj 756. Elevator

Source: Internet
Author: User

 

Elevator time limit: 1000 MS case time limit: 1000 MS memory limit: 64 MB
Total submission: 21 submission accepted: 13 description in the city's high-rise buildings, there is only one elevator, composed of n positive integers in a request list, the number in the list indicates the floor where the elevator will stop, the elevator stops in order of the list. Required for each upstream layer of the elevator
It takes 6 seconds, 4 seconds for each downstream layer, and 5 seconds for each stop of the elevator.
For the given request list, the time required to complete all requests is calculated, regardless of the priority. The elevator starts from Layer 1 and returns to layer 0th after completing all requests.

 

Input contains multiple groups of data, each of which occupies one row. The first positive integer n indicates that there are n data in the request list, followed by N integers. If n = 0, the input ends.

 

The total time of all requests output for each group of data.

 

Sample Input
Original Transformed
1 23 2 3 10

 

Sample output
Original Transformed
1741

 

Directly simulate the operation of the elevator.

 

AC code: GitHub

1/* 2 by: ohyee 3 GitHub: ohyee 4 homepage: http://www.oyohyee.com 5 Email: [email protected] 6 blog? 9) Please wait until then! 10. You need to write the code for getting started, getting started, and running ~ 11 */12 13 # include <cstdio> 14 # include <algorithm> 15 # include <cstring> 16 # include <cmath> 17 # include <string> 18 # include <iostream> 19 # include <vector> 20 # include <list> 21 # include <queue> 22 # include <stack> 23 # include <map> 24 using namespace STD; 25 26 // debug mode27 # define debug 028 29 // loop 30 # define rep (n) for (int o = 0; O <n; O ++) 31 32 bool do () {33 int N; 34 if (scanf ("% d", & N), n = 0) 35 return false; 36 37 int floor = 0; 38 int ans = 0; 39 rep (n) {40 int temp; 41 scanf ("% d", & temp ); 42 if (temp <floor) {43 ans + = 4 * (floor-Temp); 44 floor = temp; 45} 46 If (temp> floor) {47 ans + = 6 * (temp-floor); 48 floor = temp; 49} 50} 51 // ans + = floor * 4; 52 ans + = N * 5; 53 printf ("% d \ n", ANS); 54 55 return true; 56} 57 58 int main () {59 While (do (); 60 return 0; 61}

 

Aoj 756. Elevator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.