现在的位置: 首页 > 综合 > 正文

hdu 1008 水

2018年04月23日 ⁄ 综合 ⁄ 共 312字 ⁄ 字号 评论关闭

背景:水

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

int main(void){
    int t;
    while(scanf("%d",&t),t){
        int ans=0,temp1,temp2=0;
        for(int i=1;i <= t;i++){
            scanf("%d",&temp1);
            if(temp1 > temp2) ans+=(temp1-temp2)*6+5;
            else if(temp2 > temp1) ans+=(temp2-temp1)*4+5;
            else ans+=5;
            temp2=temp1;
        }
        printf("%d\n",ans);
    }
    return 0;
}

抱歉!评论已关闭.