### Geekarka's blog

By Geekarka, history, 2 weeks ago,

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.

• -2

 » 2 weeks ago, # |   0 Auto comment: topic has been updated by Geekarka (previous revision, new revision, compare).
 » 2 weeks ago, # |   0 you can check for your solution y=5
 » 2 weeks ago, # |   0 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
•  » » 13 days ago, # ^ |   0 thanks
 » 13 days ago, # |   0 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 => -1and 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 you will put all from index y to x equal to 1 but don't set the remaining to -1, except what you should do is that you need to put the one after x , and before y equal to -1 then you will move forward after x, and backward from y and each time go vice versa (if it is -1, change it to 1, and in other way) 271591027
•  » » 13 days ago, # ^ |   0 Thanks a lot!
•  » » » 13 days ago, # ^ |   0 I'm happy I could help