我是靠谱客的博主 冷艳鼠标,这篇文章主要介绍http://codeforces.com/problemset/problem/596/B,现在分享给大家,希望可以做个参考。

一路递推过去就好了。

#include <iostream>
#include <cstdio>
#include <list>
#include <stack>
#include <queue>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define INF 0x3f3f3f3f
#define  ll long long
int a[200005], n;
int main()
{
    while (cin >> n) {
        ll sum = 0;
        for (int i = 1; i <= n; ++i) {
            scanf("%d", &a[i]);
            sum = sum + abs(a[i] - a[i - 1]);
        }
        cout << sum << endl;
    }
    return 0;
}

最后

以上就是冷艳鼠标最近收集整理的关于http://codeforces.com/problemset/problem/596/B的全部内容,更多相关http://codeforces内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(140)

评论列表共有 0 条评论

立即
投稿
返回
顶部