Geekarka's blog

By Geekarka, history, 22 months ago, In English

Hello all, I'm Geekarka and I got wrong answer on pretest 2 11th testcase in my 271612109 for the problem 1990B - Array Craft of Codeforces Round 960 (Div. 2). The testcase is 5 2 1 (n=5, x=2, y=1). My output is 1 1 -1 -1 -1. The correct answer is 1 1 -1 1 -1. I will be very grateful if someone helps me understand this. Thank you.

  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
»
22 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

you can check for your solution y=5

»
22 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

it's logical error basically you are making array from index y to x as 1 and set remaining to -1 however this is a wrong idea I give you a example consider input n=11,x=7,y=6 the array will be [-1 -1 -1 -1 -1 1 1 -1 -1 -1 -1] the max prefix position will be 1 and max suffix position will be 11 because -1 is the maximum cumulative sum you can get from 1 to n or n to 1 which doesn't satisfice the input

»
22 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

this was the idea i first thought about in the contest which failed, but:

if you want to know why your answer is wrong this is because $$$y$$$ here isn't the maximum suffix position of your array, if you look at the definition, it says: the maximum suffix position of b is the largest index $$$i$$$ that satisfies ...

here in your example for y=5, the sum will be => -1

and for y=1(which should be more than $$$-1$$$) the sum will be => 1+1-1-1-1 = -1 , so the maximum suffix position in 5, not 1.

if you want to know the correct answer click the spoiler

the answer