gatecse2018's blog

By gatecse2018, history, 4 years ago, In English

Problem link: https://codeforces.net/contest/1374/problem/D Thie first test case is:
~~~~~ 4 3 1 2 1 3 ~~~~~ In the first move, increment x by 1.

So now, the array is: 1 2 1 3 and x = 1
Next move, increment 2nd element by x and increment x by 1, so: 1 3 1 3 and x = 2
Next move, increment 3rd element by x and increment x by 1, so: 1 3 3 3 and x = 3
Next move, increment x by 1, so: 1 3 3 3 and x = 4
Next move, increment x by 1, so: 1 3 3 3 and x = 5
Next move, increment 1st element by x and increment x by 1, so: 6 3 3 3 and x = 6

Total moves = 6. But this array configuration is different from the one given in the testcase explanation given under the problem. Are multiple correct configs possible? Or am I missing something?

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

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I'm assuming you're talking about Round #653, not 563.

Yes, there are multiple correct ending arrays. All you have to find is the minimum number of moves, not the final array.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes, its round 653. I have added the problem link now. The last element 3 is already divisible by k (3), so I have not done any operation on it, but the explanation has hanged it to 6. Is it necessary to do EXACTLY 1 move on each element or is it ATMOST 1?

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The problem states that The first operation can be applied no more than once to each i from 1 to n. So you do at most one operation for each element. If it was exactly one, the samples would be incorrect.