AkeenL's blog

By AkeenL, history, 3 years ago, In English

I was doing https://codeforces.com/contest/1420/problem/C1 which is a max sum alternating subsequence problem. I understand the dp solution but I fail to understand why adding the first number in the array then adding every positive arr[i] — arr[i-1] works if you have to choose numbers starting from the first element.

  • Vote: I like it
  • 0
  • Vote: I do not like it