TheOpChicken123's blog

By TheOpChicken123, history, 21 month(s) ago, In English

Hello all, I have a question about the problem in the recent div. 2 contest named in the title.

In the problem we are given a task to find a cyclical array of N numbers given the sum of local minima and local maxima. My claim is that the constraints of the question are incorrect as in an extreme case, my code will TLE.

This is because no constraint on N is given. However, the only constraints given are the sum of local minimas/maximas which is -1e9 <= X < Y <= 1e9. However, it is evident that length of the array will be 2*(X-Y). So if X = 1e9 and Y = -1e9, then N will be 2e9 won't it. And then we will have to output 2e9 numbers which will either TLE or MLE (since i am declaring an array with 2e9 integers which is a lot of space).

Am I misunderstanding? Any help will be appreciated. Thanks for reading.

UPD: I cannot read, and there was a constraint on N that said total sum of N over all test cases <= 2e5.

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

there is a line written at the end that the answer is guaranteed to exist

so the tests are that way only that it will not give n too large

»
21 month(s) ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

It was guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2*10^5$$$, which would work fine in $$$O(N)$$$.

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by TheOpChicken123 (previous revision, new revision, compare).

»
21 month(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

that's the thing with the problem, i too thought about an approach in which array size will be 2*(x-y), but because of the constraint mentioned, i thought maybe there is another approach in which array size won't have to be 2*(x-y) and also the sum of n over all test cases won't exceed 1e5 in that approach, so it was confusing