CodeForces 596B Wilbur and Array
简单题,一个一个操作,最后就是答案。
#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的更多相关文章
- 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 ...
- 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 ...
- Codeforces 442C Artem and Array(stack+贪婪)
题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...
- Codeforces Round #504 D. Array Restoration
Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...
- Codeforces Wilbur and Array
Description Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initiall ...
- 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 ...
- Codeforces 754A Lesha and array splitting(简单贪心)
A. Lesha and array splitting time limit per test:2 seconds memory limit per test:256 megabytes input ...
- Codeforces 408 E. Curious Array
$ >Codeforces \space 408 E. Curious Array<$ 题目大意 : 有一个长度为 \(n\) 的序列 \(a\) ,\(m\) 次操作,每一次操作给出 \ ...
- 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 ...
随机推荐
- 利用JSTL重写查询的jsp页面
利用JSTL重写Java Web MVC实例中的jsp页面 第一步:导入jstl.jar和standard.jar文件
- COGS 886. [USACO 4.2] 完美的牛栏
★★☆ 输入文件:stall4.in 输出文件:stall4.out 简单对比时间限制:1 s 内存限制:128 MB USACO/stall4(译by Felicia Crazy) ...
- 遍历NSView下的子视图方法
如何遍历NSView下的子视图呢 for (NSView *aview in [SuperV subviews]) { if([aview isMemberOfClass:[NSButton clas ...
- smile domain name www.bn-nd.com for sell. Please contact boyanzheng at foxmail.com 微笑的域名。请联系邮箱。
- SAS Fuctions
1. monotonic(), 单调递增函数.返回一列变量的序列等,类似于_N_ . 2. index v indexw: INDEX Function Searches a character ex ...
- PHP 中空字符串介绍0、null、empty和false之间的关系
0是数字,是empty,是false,不是null,值相当于空字符串,但类型不是字符串,去空格或强制转换为字符串型时不等于空字符串 ""的值相当于0,是empty,是空字符串,是f ...
- 基础数据类型(set集合)
认识集合 由一个或多个确定的元素所构成的整体叫做集合. 集合中的元素有三个特征: 1.确定性(集合中的元素必须是确定的) 2.互异性(集合中的元素互不相同.例如:集合A={1,a},则a不能等于1) ...
- QT_仅仅直接在构造函数中创建对象的不可行的原因
#include "mainwidget.h" #include <QApplication> int main(int argc, char *argv[]) { Q ...
- 最短路 || POJ 1797 Heavy Transportation
Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand bus ...
- 普通用户切换到root用户
普通用户切换到root用户首先按组合键 CTRL+ALT+T 进入终端界面,一般终端界面默认为普通用户权限模式,如何从普通用户进入root用户首先重置root密码输入 sudo passwd root ...