Skip to content

Latest commit

 

History

History
36 lines (32 loc) · 652 Bytes

A1008.md

File metadata and controls

36 lines (32 loc) · 652 Bytes

A1008 Elevator

1.题意理解

给出一个电梯操作序列,计算总时间

2.思路分析

直接干

3.参考代码

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++)
        scanf("%d", &v[i]);
    v[0] = 0;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int f1 = v[i], f2 = v[i + 1];
        if (f1 < f2)
            ans += 6 * (f2 - f1);
        else
            ans += 4 * (f1 - f2);
        ans += 5;
    }
    printf("%d\n", ans);
    system("pause");
    return 0;
}