Блог пользователя TheOpChicken123

Автор TheOpChicken123, история, 22 месяца назад, По-английски

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.

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
22 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
22 месяца назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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)$$$.

»
22 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
22 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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