아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

King of Hot Pot

시간 제한4초메모리 제한512 MB

요약
각 k=1부터 n까지, a_i부터 먹을 수 있고 먹는 데 b_i가 걸리는 요리 중 k개를 하나씩 먹어 끝내는 최소 시각을 구한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 힙
정답자
아직 제출이 없습니다

문제

Little Q is enjoying hot pot together with Tangjz. There are nn dishes of meat in the boiling water, labeled by 1,2,…,n1,2,\dots,n. The ii-th dish of meat will be ready at moment a_ia\_i, and it will take Little Q b_ib\_i units of time to fully eat it. Little Q can start eating dish ii at any moment t≥a_it \geq a\_i, and then he has to eat it until moment t+b_it + b\_i. Little Q can't be eating more than one dish of meat at the same time.

Little Q is called "King of Hot Pot", and he wants to show off before Tangjz by fully eating kk dishes of meat as soon as possible. The timer starts at moment 00. Please write a program to help Little Q, for each kk independently (1≤k≤n1 \leq k \leq n), find kk dishes of meat and the order to eat them such that the total time before he fully eats kk dishes is minimized. Note that any waiting time is also included in the answer.

입력

The first line contains a single integer TT (1≤T≤10,0001 \leq T \leq 10\\,000), the number of test cases. For each test case:

The first line contains an integer nn (1≤n≤300,0001 \leq n \leq 300\\,000) denoting the number of dishes of meat.

Each of the following nn lines contains two integers a_ia\_i and b_ib\_i (1≤a_i,b_i≤1091 \leq a\_i, b\_i \leq 10^9) describing a dish of meat.

It is guaranteed that the sum of all nn is at most 1,000,0001\\,000\\,000.

출력

For each test case, output a single line containing nn integers, the kk-th (1≤k≤n1 \leq k \leq n) of which is the minimum total time before Little Q can fully eat kk dishes of meat.

예제1

  1. 예제 1

    입력
    1
    5
    1 2
    4 6
    3 5
    4 2
    3 2
    
    예상 출력
    3 5 7 12 18