`
风吹过PP好冷
  • 浏览: 36645 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

PAT1008 Elevator

    博客分类:
  • PAT
 
阅读更多

电梯上升一层6秒,下降一层4秒,每层停留5秒

Sample Input: 
3 2 3 1 
Sample Output: 
41 

 

 

 

 

 

#include <iostream>
using namespace std;

int main()
{
    int N;
    cin>>N;
    int current = 0;
    int total = 0;
    while (N--)
    {
        int a;
        cin>>a;
        if (a >= current)
        {
            total += (a - current) * 6  + 5;
            current = a;
        }
        else
        {
            total += (current - a) * 4 + 5;
            current = a;
        }
    }
    cout<<total;
    return 0;
}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics