Unfortunately the question is not clear at all. I would like to understand the kind of construction you have, and then why it takes you $O(n^2)$ to compute. Before that, I think it will be difficult for people to help...
–
Rodrigo A. PérezDec 4 '12 at 6:13

Included the image, but I agree that more explanation is needed.
–
David RobertsDec 4 '12 at 6:52

Ok, maybe different approach: Let f(x) be our main function where 0 \leq x \leq n and another function is h(x) where 0 \leq x \leq m with one maximum h(b) (ofc 0 \leq b \leq m). I need to compute the following: G(x)=\max(f(x),\max{_{0\leq k\leq m}} \{h(k)+f(x+b-k)\}) for every x. But i think this is even less clear. I have problem with explaining it coz of my bad english. Try to imagine you have h function with one maximum at b, now for every x you have to move h by some vector to match h(b)=f(x) and compute maximum of this two functions.
–
ithinksoDec 4 '12 at 7:24

Ok, maybe different approach: Let $f(x)$ be our main function where $0 \leq x \leq n$ and another function is $h(x)$ where $0 \leq x \leq m$ with one maximum $h(b)$ (ofc $0 \leq b \leq m$). I need to compute the following: $G(x)=\max(f(x),\max{_{0\leq k\leq m}} \{h(k)+f(x+b-k)\})$ for every x. But i think this is even less clear. I have problem with explaining it coz of my bad english. Try to imagine you have h function with one maximum at b, now for every x you have to move h by some vector to match $h(b)=f(x)$ and compute maximum of this two functions.
–
ithinksoDec 4 '12 at 7:27