#P7542. [COCI 2009/2010 #1] MALI

[COCI 2009/2010 #1] MALI

Description

Mirko and Slavko are playing a game. The game has a total of NN rounds. In round kk, Slavko gives two integers AkA_k and BkB_k. Please help Mirko solve the following problem:

In the first kk rounds, Slavko has given the numbers A1,A2,...,AkA_1, A_2, ..., A_k and B1,B2,...,BkB_1, B_2, ..., B_k. Pair these numbers into kk pairs (Ai,Bj)(A_i, B_j) (1i,jk1 \le i, j \le k), such that every number in sequence AA and every number in sequence BB appears exactly once among these pairs, and the maximum value among the sums of all pairs (Ai+BjA_i + B_j) is minimized.

Input Format

The first line contains an integer NN, indicating the number of rounds in the game.

The next NN lines each contain two integers Ai,BiA_i, B_i, indicating the two numbers Slavko gives in round ii.

Output Format

Output NN lines. The ii-th line should be the minimum possible maximum pair sum after round ii.

3
2 8
3 1
1 4
10
10
9
3
1 1
2 2
3 3
2
3
4

Hint

Constraints

For 50%50\% of the testdata, 1N2001 \le N \le 200.

For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 1Ai,Bi1001 \le A_i, B_i \le 100.

Notes

The scoring of this problem follows the original COCI problem settings, with a full score of 100100.

Translated from COCI2009-2010 CONTEST #1 T4 MALI.

Translated by ChatGPT 5