简单题,一个一个操作,最后就是答案。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; long long a[+];
long long pre;
int n; int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%lld",&a[i]);
pre=;
long long ans=;
for(int i=;i<=n;i++)
{
ans=ans+abs(a[i]-pre);
pre=a[i];
}
printf("%lld\n",ans);
return ;
}

CodeForces 596B Wilbur and Array的更多相关文章

  1. Codeforces Round #331 (Div. 2) B. Wilbur and Array 水题

    B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  2. Codeforces Round #331 (Div. 2) B. Wilbur and Array

    B. Wilbur and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces 442C Artem and Array(stack+贪婪)

    题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...

  4. Codeforces Round #504 D. Array Restoration

    Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...

  5. Codeforces Wilbur and Array

    Description Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initiall ...

  6. Educational Codeforces Round 21 D.Array Division(二分)

    D. Array Division time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  7. Codeforces 754A Lesha and array splitting(简单贪心)

    A. Lesha and array splitting time limit per test:2 seconds memory limit per test:256 megabytes input ...

  8. Codeforces 408 E. Curious Array

    $ >Codeforces \space 408 E. Curious Array<$ 题目大意 : 有一个长度为 \(n\) 的序列 \(a\) ,\(m\) 次操作,每一次操作给出 \ ...

  9. Educational Codeforces Round 11A. Co-prime Array 数学

    地址:http://codeforces.com/contest/660/problem/A 题目: A. Co-prime Array time limit per test 1 second me ...

随机推荐

  1. Understanding Scroll Views 深入理解 scroll view 读书笔记

    Understanding Scroll Views 深入理解 scroll view  读书笔记   It may be hard to believe, but a UIScrollView is ...

  2. 【HEVC简介】SAO-Sample Adaptive Offset, 样本自适应偏移量

    paper: Sample Adaptive Offset for HEVC <HEVC标准介绍.HEVC帧间预测论文笔记>系列博客,目录见:http://www.cnblogs.com/ ...

  3. qt QTableView/QTableWidget样式设置

    转载请注明出处:http://www.cnblogs.com/dachen408/p/7591409.html 选中设置: QTableView::item:selected { background ...

  4. CentOS 7上修改主机名

                                       如何在CentOS 7上修改主机名                                           在Cent ...

  5. Format a Hard Drive in Csharp

    Article Author(s): Audric Thevenet All Rights Reserved. Here's how to format hard drives, floppies, ...

  6. Java集合(四)--基于JDK1.8的ArrayList源码解读

    public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess ...

  7. flex布局以及相关属性

    容器的属性: 父元素设置display:flex:子元素即可使用flex布局. flex-direction 决定项目排列方向: .box { flex-direction: row | row-re ...

  8. 爬虫学习之第一次获取网页内容及BeautifulSoup处理

    from urllib.request import urlopen from urllib.request import HTTPError from bs4 import BeautifulSou ...

  9. c++_方格填数(最新方法)

      方格填数 如下的10个格子 +--+--+--+ | | | |+--+--+--+--+| | | | |+--+--+--+--+| | | |+--+--+--+ (如果显示有问题,也可以参 ...

  10. 关于flock文件锁的阻塞与非阻塞

    阻塞模式,程序会一直等待. <?php $fp = fopen("lock.txt", "r"); if(flock($fp,LOCK_EX)) { // ...