Блог пользователя aman_naughty

Автор aman_naughty, история, 5 лет назад, По-английски

Problem link: link

My code

Spoiler

We have 2 choices for each element either + or — I am considering both the choices and then picking the optimal one. In the code the dp[i].first = the minimum number of sign inversions dp[i].second = the optimal sum we achieve by either inverting this one or not;

It fails on array 10 4 3 2 1

Can someone point out why my aaproach is wrong?

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится