Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

need help in a finished coding round problem

Revision en1, by user311, 2021-09-20 14:37:41

We are given a sequence A = {a1, a2, ... , an} which is index wise sum of two sequences B = {b1, b2, ... , bn} and C = {c1, c2, ... ,cn}.

i.e. a1 = b1 + c1, a2 = b2 + c2 , ... , an = bn + cn

B is non decreasing and C is non increasing.

Find the minimum possible value of abs(b1) + abs(b2) + ... + abs(bn) + abs(c1) + abs(c2) + ... + abs(cn).

Constraint — array size <= 2e5, -1e8 < a[i] < 1e8.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English user311 2021-09-20 14:37:41 460 Initial revision (published)