hdu 2713
#include<stdio.h>
#include<string.h>
int map[151000][2];
int max(int a,int b) {
return a>b?a:b;
}
int main() {
int n,d;
while(scanf("%d",&n)!=EOF) {
memset(map,0,sizeof(map));
int i=0;
map[i][0]=0;
map[i][1]=0;
i++;
while(n--) {
scanf("%d",&d);
map[i][0]=max(map[i-1][1]+d,map[i-1][0]);
map[i][1]=max(map[i-1][0]-d,map[i-1][1]);
i++;
}
printf("%d\n",map[i-1][0]);
}
return 0;
}
hdu 2713的更多相关文章
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
随机推荐
- 51nod 1526 分配笔名
题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 320 难度:7级算法题. 班里有n个同学.老师为他们选了n个笔名.现在要把这些笔名分配给每一个同学,每一 ...
- C# 重写(override)和覆盖(new)
重写 用关键字 virtual 修饰的方法,叫虚方法.可以在子类中用override 声明同名的方法,这叫“重写”.相应的没有用virtual修饰的方法,我们叫它实方法.重写会改变父类方法的功能. ...
- Html5怎么导出图片
其实很简单, 首先需要两个js文件 jquery.min.js html2canvas.js 直接上代码,几行就解决了 <a id="example1" onclick=&q ...
- Android之父Andy Rubin:被乔布斯羡慕嫉妒的天才
今年中国掀起一股“苹果热”,智能手机iPhone.平板电脑iPad遭疯抢,一度卖断货.然而,令许多人意想不到的是,在“苹果”的老家——美国市场,智能手机中卖得最火的并不是iPhone,而是Androi ...
- ubuntu 16.04 安装node.js 8.x
引自 https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04#how-to-in ...
- bzoj3545 [ONTAK2010]Peaks、bzoj3551 [ONTAK2010]Peaks加强版
题目描述: bzoj3545,luogu bzoj3551 题解: 重构树+线段树合并. 可以算是板子了吧. 代码(非强制在线): #include<cstdio> #include< ...
- 【图论】hdu6370Werewolf
有理有据的结论题 Problem Description "The Werewolves" is a popular card game among young people.In ...
- css3如何实现click后页面过渡滚动到顶部
var getTop = document.getElementById("get-top"); var head = document.getElementById(" ...
- 关于get_magic_quotes_gpc()函数
function sqlReplace($str) { $strResult = $str; if(!get_magic_quotes_gpc()) //如果 gpc 没有开的话 { $strResu ...
- Java中IO流讲解(一)
一.概念 IO流用来处理设备之间的数据传输 Java对数据的操作是通过流的方式 Java用于操作流的类都在IO包中 流按流向分为两种:输入流,输出流 流按操作类型分为两种: 字节流 : 字节流可以操作 ...