PAT 1008

来源:互联网 发布:下载微客多软件 编辑:程序博客网 时间:2024/05/17 12:00
#include <iostream>using namespace std;int main(){int N;cin >> N;int next, now = 0, sum = 0;while (N--){cin >> next;if (next - now > 0){sum += 6 * (next - now) + 5;}else {sum += 4 * (now - next) + 5;}now = next;}cout << sum << endl;return 0;}

0 0
原创粉丝点击