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 }
原文地址:https://www.cnblogs.com/invisible/p/2402899.html