Codeforces doubt

https://codeforces.com/contest/1499/problem/C
I am unable to solve this question even after seeing the editorial .kindly help

hello @Somasree

note following things.

a) segements will be alternate ,(i,e if first segment is up then next segment will be right and vice versa)

b) sum of total up segment will be n (becuase we have to go from 0 to n )
c) sum of total right segment will be n ( (becuase we have to go from 0t to n).
d) now try greedy approach, i.e pick ci which has minimum cost and at same parity and use it to cover maximum length.

if still it is not clear then refer this video editorial->
link

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.