当前位置: 代码迷 >> 综合 >> HDU-1008(基础题)
  详细解决方案

HDU-1008(基础题)

热度:51   发布时间:2023-12-17 13:41:34.0

思想;跟据题意进行编程即可【注意每次与上一个数进行比较】;
代码:

 #include <iostream>#include <cstdio>#include <cstring>#include <map>#include <algorithm>#include <sstream>#include <set>#include <string>#include <stack>#include <vector>
using namespace std;
const int N = 50;
typedef long long LL;
const int inf = 0x3f3f3f3f;int main()
{LL n;while(cin>>n&&n){LL m,ml,t=0;cin>>m;t+=m*6;for(int i=1;i<n;i++){cin>>ml;if(ml>=m)t+=(ml-m)*6;elset+=(m-ml)*4;m=ml;}cout<<t+5*n<<endl;}return 0;
}