# poj 2181 Jumping Cows

#include<iostream>
#include<string.h>
#include<math.h>
#include<fstream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector>
#define MAXSIZE 100
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))
int P = 0;
int dp[150010];
int dat[150010];
int incr[150010], decr[150010];
int main()
{
//freopen("data_2181.txt","r",stdin);
while(scanf("%d", &P) != EOF)
{
for (int i = 1; i <= P; i++)
{
scanf("%d", &dat[i]);
}
for (int i = 1; i <= P; i++)
{
incr[i] = max (incr[i - 1], decr[i - 1] + dat[i]);
decr[i] = max (decr[i - 1], incr[i - 1] - dat[i]);
}
printf("%d\n", max (incr[P], decr[P]));
}

return 0;
}

#### Jumping Cows

2008-03-21 12:36:00

#### poj 2181 Jumping Cows DP

2011-08-17 14:29:55

#### 2181 Jumping Cows 解题报告

2009-03-04 11:37:00

#### POJ 3615 Cow Hurdles （Floyd算法）

2015-01-14 23:51:47

#### POJ 2181 Jumping Cows

2013-01-08 01:02:32

#### POJ 3615 Cow Hurdles Floyd算法的变体

2011-01-23 23:54:00

#### POJ 2181 Jumping Cows [贪心]

2012-03-29 20:29:06

#### poj 2181 Jumping Cows 贪心

2017-04-19 20:45:53

#### POJ 2181 JUMPING COWS(DP)

2011-08-19 20:01:51

#### FOJ 1544 PKU 3615 Cow Hurdles

2008-08-08 08:58:00