Problem list
Log in
#coci00644 · COCI 2022/2023 Contest 4

Vrsta

Platinum IV 1.0 s 512 MB

Domagoj’s favorite school subject is P.E. Every P.E. class starts with warm-up exercises. The teacher has an interesting way of choosing the student who will lead the warm-up. The students stand in a line sorted by their height. The teacher will choose the student that is standing in the middle of the line. If two students are in the middle, he will choose the shorter one. For example: if the students have heights 1 3 5 7 11, the student with height 5 will lead the warm-up exercises. Domagoj does not remember how tall his classmates are. Luckily, next to him stands Lovro who is very good at estimating people’s heights. He gives Domagoj $n$ statements: “There are $a_{i}$ students entering the gym with height $v_{i}$”. After every statement said by Lovro, Domagoj is interested in the height of the student who will lead the warm-up, if only the students who entered the gym come to P.E. class. Help him answer his questions!

Input

The first line contains the integer $n$ ($1 \le n \le 200$, 000), the number of Lovro’s statements. The following $n$ lines contain two integers $v_{i}$, $a_{i}$ ($1 \le v_{i}$, $a_{i} \le 10^{9}$), the height and the number of students in Lovro’s statement.

Output

In the $i$-th of $n$ lines output the answer to Domagoj’s question after $i$ of Lovro’s statements.

Example 1

Input
3
2 1
3 1
1 1
Output
2
2
2

Example 2

Input
4
17 2
23 5
11 4
9 5
Output
17
23
17
11

Example 3

Input
3
10 20
100 5
1000 5
Output
10
10
10
Source
COCI 2022/2023 Contest 4
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code