Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

mayank0802's blog

By mayank0802, history, 6 months ago, In English,
 
 
 
 
  • Vote: I like it
  • +15
  • Vote: I do not like it

»
6 months ago, # |
  Vote: I like it +10 Vote: I do not like it

I'm under the impression that whenever you decrement some value it's optimal to take it all the way down to 1. Therefore, you can go for a dynamic programming approach to solve the problem, where dp[i][flag] = largest possible answer for the i-th prefix and flag indicates if the last element stayed at his value or if he was reduced to 1.

»
6 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it
code
  • »
    »
    6 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Nobody got an AC on this problem, was there some problem with it's test cases?

    solution
»
4 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

Congratulation for creating the 69420th blog of codeforces