首页 > 其他 > 详细

HDU 2713: Jumping Cows

时间:2017-09-11 22:23:16      阅读:183      评论:0      收藏:0      [点我收藏+]


///@ref geeksforgeeks
///@author Sycamore
///@date 9/11/2017
///@link http://acm.hdu.edu.cn/showproblem.php?pid=2713
#include<bits/stdc++.h>
using namespace std;
int m[150001][2];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int P,s;
	while (cin >> P)
	{
 
		m[0][0] = m[0][1] = 0;
		for (int i = 1; i <= P; i++)
		{
			cin >> s;
			m[i][0] = max(m[i-1][0], m[i - 1][1] + s);
			m[i][1] = max(m[i-1][1], m[i - 1][0] - s);
		}
		cout << max(m[P][0], m[P][1])<<‘\n‘;
	}
	return 0;
}

 

HDU 2713: Jumping Cows

原文:http://www.cnblogs.com/zjnu/p/7507145.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!