arifin_fuad_kashfy's blog

By arifin_fuad_kashfy, history, 2 hours ago, In English

300520956 got wa and it get AC 300520087

»
2 hours ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

You are updating $$$k$$$ after updating $$$vec_i$$$, if you set $$$vec_i$$$ to be equal to $$$vec_{i-1}$$$ this will not make the value of $$$k$$$ change when it should be reduced

1
4 2
8 6 4 2

The answer for the following test should be $$$2$$$, you update $$$6$$$ to be equal to $$$8$$$ and the final score is:

$$$8 - 8$$$ + $$$4 - 2 = 2$$$

but your code does not update $$$k$$$ ($$$k$$$ remains $$$2$$$) which leads to the final $$$2$$$ being increased to $$$4$$$ making the result $$$0$$$

Here I modified your code to update $$$k$$$ correctly: 300523709