HDU 2713: Jumping Cows
///@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
相關推薦
HDU 2713: Jumping Cows
cow geeks author ace [0 pro pid space pin ///@ref geeksforgeeks ///@author Sycamore ///@date 9/11/2017 ///@link http://acm.hdu.edu.cn/sho
[poj2181]jumping cows
ans std 增加 abi space spa strength dmi closed poj 2181 Jumping Cows Description Farmer John‘s cows would like to jump over the moon, just
POJ 2181 -- Jumping Cows
single namespace class table art memory 但是 incr efi Jumping Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissi
HDU - 3045 - Picnic Cows [ 斜率優化dp ]
Problem Describe It’s summer vocation now. After tedious milking, cows are tired and wish to take a holiday. So Farmer Carolina considers havi
1596: Jumping Cows (貪心)
1596: Jumping Cows 時間限制(普通/Java):1000MS/10000MS 記憶體限制:65536KByte 描述 Farmer John's cows would like to jump over the moo
HDU 3045 Picnic Cows [DP斜率優化]
題意:給你長度為n的數列,將其中的數劃分為幾個部分,每個部分數的個數要大於等於T,每個部分的val是每個數減去最小值的總和,求val和的最小值。 題解:首先肯定是將數列排序,定義dp[i]表示,計算到i時答案的總和最小值,這樣我們的轉移是O(n^2)的。 根據題意可以列出,
HDU 1087 Super Jumping! Jumping! Jumping!
blog col som oss score ++ all you finall Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU.
Super Jumping! Jumping! Jumping! HDU - 1087
std idt scribe cas abs roc assume led cor Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU
E - Super Jumping! Jumping! Jumping! <HDU 1087>
describe sam test RoCE anti pac end line backward E - Super Jumping! Jumping! Jumping! Nowadays, a kind of chess game called “Super Jumpi
HDU 1087 Super Jumping! Jumping! Jumping
Super Jumping! Jumping! Jumping! Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a
[LIS_最長遞增子序列]-hdu 1087 Super Jumping!
[LIS_最長遞增子序列]-hdu 1087 Super Jumping! 標籤: ACM 題意: Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very
HDU-1087-Super Jumping! Jumping! Jumping! (dp)
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this
HDU-1087-Super Jumping! Jumping! Jumping!(DP+上升子序列)
Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know litt
hdu 1087 Super Jumping!(dp)
思路:動態規劃的三個原則是:1.子問題重疊性2.無後效性3.子結構最優性 如果這題把dp[i]當成前i個數的最長上升子序列的話,那第i+1個數會影響前i個數的選擇,比如 5 6 1 2 3;第i+1個
hdu - 1087 Super Jumping! Jumping! Jumping!(dp)
題目:http://acm.hdu.edu.cn/showproblem.php?pid=1087 題意:n個數組成的序列中,求最大遞增子序列的和。 dp思路:和最長遞增子序列類似,只不過dp陣列中儲存的是序列和而不是序
動態規劃HDU-1087 Super Jumping! Jumping! Jumping!
題目連結:點選開啟連結 題目: Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768
每日三題-Day2-C(HDU 1087 Super Jumping! Jumping! Jumping! 最大上升子序列和)
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game,
hdu 1087 Super Jumping! Jumping! Jumping!(dp 最長上升子序列和)
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game,
hdu 4719 Oh My Holy FFF(dp線段樹優化)
origin end should adding href ast left code padding Oh My Holy FFF Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 65535/65535
HDU 1114 Piggy-Bank(完全背包)
ask style span ica ace eno eterm ++ empty 題目: Before ACM can do anything, a budget must be prepared and the necessary financial support o