1. 程式人生 > >杭電OJ——1024 Max Sum Plus Plus(另類的動態規劃!)

杭電OJ——1024 Max Sum Plus Plus(另類的動態規劃!)

Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem.

Given a consecutive number sequence S1, S2, S3, S4 ... Sx, ... Sn (1 ≤ x ≤ n ≤ 1,000,000, -32768 ≤ Sx ≤ 32767). We define a function sum(i, j) = Si + ... + Sj (1 ≤ i ≤ j ≤ n).

Now given an integer m (m > 0), your task is to find m pairs of i and j which make sum(i1, j1) + sum(i2, j2) + sum(i3, j3) + ... + sum(im
, jm) maximal (ix ≤ iy ≤ jx or ix ≤ jy ≤ jx is not allowed).

But I`m lazy, I don't want to write a special-judge module, so you don't have to output m pairs of i and j, just output the maximal summation of sum(ix, jx)(1 ≤ x ≤ m) instead. ^_^

相關推薦

OJ——1024 Max Sum Plus Plus動態規劃

Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you a

1024----Max Sum Plus Plus

int oid max art main 杭電 sca ava 最大 1 /* 2 這題還沒有理解透徹。某個dalao也不寫註釋。只能自己理解了。。。 3 先求為i個元素(1<=i<=M)為一個區間的最大和,保證元素個數大於等於i個,遞推到M個即可 4

1024 Max Sum Plus Plus

Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you a

hdu 1024 Max Sum Plus Plus (子段和最大問題)

got mil 計算 itl tex seq panel gin enter Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (

hdu-1024 Max Sum Plus Plus

ott string for style lazy names cin roc pair Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja

hdu-1024 Max Sum Plus Plus

ati integer 最大連續 fun plus con begin 二維數組 and Now I think you have got an AC in Ignatius.L‘s "Max Sum" problem. To be a brave ACMer, we al

HDU - 1024 Max Sum Plus Plus(dp+滾動數組優化)

std scanf strong mes stat 方程 color ati algo 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1024 題意:給定n個數字,求其中m段的最大值(段與段之間不用連續,但是一段中要連續)

HDU - 1024 Max Sum Plus Plus 滾動數組優化

發現 數字 iostream ret mes urn 數組 static 是否 給定n個數字,求其中m段的最大值(段與段之間不用連續,但是一段中要連續) 例如:2 5 1 -2 2 3 -1五個數字中選2個,選擇1和2 3這兩段。 dp[i][j]從前j個數字中選擇i段,然

HDU 1024 Max Sum Plus Plus基礎dp)

always cut panel face make return algo pan nbsp Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K

hdu 1024 Max Sum Plus Plus 小白都可以看得懂的解析

acm這道題弄了很久,網上的很多都看不懂,所以想要寫一個像我這種菜鳥都可以看得懂的解析。題意是將一個長度為n的序列,分成m段不相交叉的子段,使得他們的和最大。於是可以用dp[i][j]來表示在前j個數中,以num[j]結尾並分為i段的最大和。此時我們可以得出一個式子,dp[i][j]=max(dp[i-1][

hdu 1024 Max Sum Plus Plus

題意 n個數取m個不重合的部分使和最大,求這個最大值。 思路 列舉比大小的思路肯定不可取,嘗試動態規劃。 動態規劃最自然的想法是:求n個數取若干部分和的最大值,子問題就是對n-1個數取若干部分和的最大值

HDU 1024 Max Sum Plus Plus最大m子段和

Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. No

hdu 1024 Max Sum Plus Plus動態規劃+m子段和的最大值

Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you ar

1024 Max Sum Plus PlusDP + 滾動陣列

題目大意:求m個不相交區間的最大和 解題思路:這題是參考別人的,傳送門 再自己組織一下,用dp[i][j]表示前j個數組組成了i個不相交區間的最大和,其中第j個數字一定在某個區間內 那現在要決策的是,第j個數組是在和別的陣列成了一個區間,還是自己獨立成了一

hdu 1024 Max Sum Plus Plus(m段最大和)

inf col ati ace NPU cme out cout long Problem Description Now I think you have got an AC in Ignatius.L‘s "Max Sum" problem. To be a brav

hdu1024HDU 1024 Max Sum Plus Plus動態規劃 很詳很詳解

Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6725    Ac

近幾年OJ大型比賽題目合集【更新到2017年10月】

杭電 網絡賽 2016年 fin 區域賽 現場賽 2015年 font strong 2017年: 區域賽網絡賽 6194~6205 6206~6216 2016年: 區域賽網絡賽 5868~5877 5878~5891 5892~5901 區域賽

oj 1106

total rip memory spa 除開 scan long tdi else 排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su

sincerit-oj 1237 簡單計算器

1237 簡單計算器 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26856 Accepted Submission(s): 9

【ACM】OJ 2015

    #include <iostream> using namespace std; int main () { int count,sum,i,j,m,n; while(scanf("%d%d",&m,&n)==2) {