Maximum of (a[i]+a[j])*(j — i) where j > i

Revision en1, by amr0, 2021-02-06 07:54:21

Hello Codeforces! I was trying to solve https://codeforces.me/gym/102920/problem/L using divide and conquer. To get the solution that crosses the midpoint I use the observation that the left endpoint, at index i, will be in a monotonically increasing sequence and the right endpoint, at index j, will be in a monotonically decreasing sequence but I get TLE. This is a code snippet from the code I submitted: https://ideone.com/pRWLDD . Your help is appreciated

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English amr0 2021-02-06 07:54:21 505 Initial revision (published)