⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2108.cpp

📁 ZOJ 动态规划算法题目入门与提高 源代码
💻 CPP
字号:
#include<iostream>
#include<fstream>

using namespace std;

int main()
{
     ifstream cin("in.txt");
     int N;
     while(cin>>N && N)
     {
         int pre = 0,now,d=0;
         int total = 0;
         while(N--)
         {
             cin >> now;
             d = now - pre;
             if(d > 0) total += (6*d);
             else if(d < 0) total += (4*(-d));
             total += 5;
             pre = now;
         }
         cout<<total<<'\n';
         
     }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -