Helping an ex-cs student touch grass while blindfolded with my insane programming skills in another world

Chicken's Last Wish
time limit per test
0.5 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

Gone are the days Chicken needs to do IO. So much time has already been spent on IO that he needs to touch grass. Very fortunately, there are 2 arrays a and b in front of him. Interestingly, the kth element of array $$$a$$$, $$$a_k$$$ is defined to be grass if $$$$$$\sum_{i = 1}^n |a_k - a_i| \le \sum_{i = 1}^n |b_k - b_i|$$$$$$ Regrettably, Chicken has not touched grass for a long time. Hence he does not know which elements are grass. Luckily you are here to help him find grass, can you help him?

Much to both of your surprise, just as you were about to help him, disaster struck! 1 weird guy named $$$אתבש$$$, who proclaimed himself as Chicken's personal array adjuster showed up and blindfolded the 2 of you, making you unable to see the array, as an act of revenge for failing to get NOI Gold by 1 point before proceeding to get run over by truck-kun. Gravely, Chicken tells you that he wants to touch grass before he dies. Xeric conditions coupled with nearby grass have caused you to lose all your energy, but you are determined to help Chicken fulfill his last wish.

Input

The first line of input is an integer t, representing the index of the testcase. As you are blindfolded, you cannot see the array nor its changes and hence there is no other input. However, the format of the arrays, as well as that of the updates remain the same as in findinggrass.

Output

Before the first update, and after every update, output any integer $$$k$$$ such that $$$a_k$$$ is grass. If there is no such integer, output −1 instead.

Scoring

For all subtasks, it is guaranteed that:

  • $$$0\leq N, Q\leq 2\cdot 10^5$$$
  • $$$-10^9\leq a_i, b_i, v_i\leq 10^9$$$
  • $$$1\leq t_i\leq 2$$$
  • $$$1\leq x_i\leq N$$$
SubtaskScoreNQAdditional Constraints
17$$$N\leq 2000$$$$$$Q\leq 50$$$
216$$$N\leq 2\cdot 10^4$$$$$$Q\leq 50$$$
324$$$N\leq 2\cdot 10^4$$$$$$Q\leq 10^4$$$
426$$$1\leq a_i,b_i,v_i\leq2\cdot 10^5$$$
527

Note

As $$$אתבש$$$ has reincarnated as a spoon in another world, he is unable to provide sample testcases.

As Chicken has dementia, he cannot remember things properly and memory limit is reduced. He will die soon, hence time limit is also reduced.

Chicken's chinese neighbour plays the violin instead of the piano in this version and does not know binary search instead of sorting

While trying to solve the problem, a Rust fan trashes on you for using C++

$$$אתבש$$$ likes golden and legendary numbers

You may not give Chicken up or let him down

You may not take off your blindfolds

Chicken has never been to a Sawcon, though he would love to.



Submitting to 'Helping an ex-cs student touch grass while blindfolded with my insane programming skills in another world'


You're not logged in! Click here to login


Submitting to 'Helping an ex-cs student touch grass while blindfolded with my insane programming skills in another world'


You're not logged in! Click here to login


Submitting .cpp to 'Helping an ex-cs student touch grass while blindfolded with my insane programming skills in another world'


You're not logged in! Click here to login

Time Limit: 0.5 Seconds
Memory Limit: 64MB
Your best score: 0
Source: April Fools 2023 (siewjh)

Subtask Score
1 7
2 16
3 24
4 26
5 27