zoukankan      html  css  js  c++  java
  • AOJ 756.电梯

    电梯
    Time Limit: 1000 ms   Case Time Limit: 1000 ms   Memory Limit: 64 MB
    Total Submission: 21   Submission Accepted: 13
     
    Description
    在城市的高层建筑物中,只有一部电梯,由N个正整数组成一个请求列表,列表中的数字表示电梯将在哪层停,电梯按列表顺序依次停靠。电梯每上行一层需要
    花6秒时间,每下行一层需要花4秒时间,电梯每停一次需要用时5秒。
    对于给定的请求列表,计算完成所有请求需要花费的时间,不考虑优先顺序,电梯从第0层开始,完成所有请求后又回到第0层。
    Input
    包含多组数据,每组数据占一行,其中第一个正整数N表示请求列表中有N个数据,接下来是N个整数,如果N=0,则表示输入结束。
    Output
    对每组数据,输出所有请求的总时间。
    Sample Input
    Original Transformed
    1 2
    3 2 3 1
    0
    Sample Output
    Original Transformed
    17
    41

    直接模拟电梯的运行即可

    AC代码:GitHub

     1 /*
     2 By:OhYee
     3 Github:OhYee
     4 HomePage:http://www.oyohyee.com
     5 Email:oyohyee@oyohyee.com
     6 Blog:http://www.cnblogs.com/ohyee/
     7  
     8 かしこいかわいい?
     9 エリーチカ!
    10 要写出来Хорошо的代码哦~
    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 MODE
    27 #define debug 0
    28  
    29 //循环
    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
    ",ans);
    54  
    55     return true;
    56 }
    57  
    58 int main() {
    59     while(Do());
    60     return 0;
    61 }
  • 相关阅读:
    共望明月
    游丽都公园有感
    创业天才尼尔曼迈向成功的十四个原则
    赵娜(帮别人名字作诗)
    小幽默也有大道理:哲理幽默15则
    夜游草堂
    成功就是简单的事情重复做、重复做
    千万别入错行 15条人生建议
    听一堂课值三十九万,把它看完,定会有收获!
    VIEW:X$KCCRSControlfile Record Section directory (8.0 8.1)
  • 原文地址:https://www.cnblogs.com/ohyee/p/5496530.html
Copyright © 2011-2022 走看看