zoukankan      html  css  js  c++  java
  • 1008. Elevator

    C++语言: Codee#25856
    01 /*
    02 +++++++++++++++++++++++++++++++++++++++
    03                 author: chm
    04 +++++++++++++++++++++++++++++++++++++++
    05 */
    06
    07 #include <map>
    08 #include <set>
    09 #include <list>
    10 #include <queue>
    11 #include <cmath>
    12 #include <stack>
    13 #include <bitset>
    14 #include <cstdio>
    15 #include <cctype>
    16 #include <string>
    17 #include <vector>
    18 #include <cassert>
    19 #include <cstdlib>
    20 #include <cstring>
    21 #include <fstream>
    22 #include <sstream>
    23 #include <iomanip>
    24 #include <iostream>
    25 #include <algorithm>
    26
    27 using namespace std;
    28
    29 FILE*            fin         = stdin;
    30 FILE*            fout         = stdout;
    31 const int        max_size     = 10086;
    32 #define ONLINE_JUDGE
    33 int main()
    34 {
    35 #ifndef ONLINE_JUDGE
    36     freopen("d:\\in.txt", "r", stdin);
    37     freopen("d:\\out.txt", "w", stdout);
    38 #endif
    39     int n;
    40     int tmp;
    41     int cur = 0;
    42     int cost = 0;
    43     scanf("%d", &n);
    44     while(n--)
    45     {
    46         scanf("%d", &tmp);
    47         if(tmp > cur)
    48             cost += (tmp - cur) * 6;
    49         else
    50             cost += (cur - tmp) * 4;
    51         cur = tmp;
    52         cost += 5;
    53     }
    54     printf("%d\n", cost);
    55
    56 #ifndef ONLINE_JUDGE
    57     fclose(stdout);
    58     system("start d:\\check.exe d:\\out.txt d:\\ans.txt");
    59 #endif
    60     return 0;
    61 }
  • 相关阅读:
    poj 2754 Similarity of necklaces 2 转换成多重背包,单调队列优化/ 二进制优化
    new和delete2
    new和delete1
    new和delete4
    new和delete3
    new(placement new)
    用例图中的Actor(参与者)一定是人吗?
    二维数组的函数参数传递
    二维指针动态创建二维数组(C/C++)
    OOD的五项基本原则——SOLID
  • 原文地址:https://www.cnblogs.com/invisible/p/2402899.html
Copyright © 2011-2022 走看看