Logo
(追記) (追記ここまで)

20611번 - King of Hot Pot 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB132432.564%

문제

Little Q is enjoying hot pot together with Tangjz. There are $n$ dishes of meat in the boiling water, labeled by 1,2,ドル\dots,n$. The $i$-th dish of meat will be ready at moment $a_i,ドル and it will take Little Q $b_i$ units of time to fully eat it. Little Q can start eating dish $i$ at any moment $t \geq a_i,ドル and then he has to eat it until moment $t + 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 $k$ dishes of meat as soon as possible. The timer starts at moment 0ドル$. Please write a program to help Little Q, for each $k$ independently (1ドル \leq k \leq n$), find $k$ dishes of meat and the order to eat them such that the total time before he fully eats $k$ dishes is minimized. Note that any waiting time is also included in the answer.

입력

The first line contains a single integer $T$ (1ドル \leq T \leq 10,000円$), the number of test cases. For each test case:

The first line contains an integer $n$ (1ドル \leq n \leq 300,000円$) denoting the number of dishes of meat.

Each of the following $n$ lines contains two integers $a_i$ and $b_i$ (1ドル \leq a_i, b_i \leq 10^9$) describing a dish of meat.

It is guaranteed that the sum of all $n$ is at most 1ドル,000円,000円$.

출력

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

제한

예제 입력 1

1
5
1 2
4 6
3 5
4 2
3 2

예제 출력 1

3 5 7 12 18

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2020 > Day 3: Songyang Chen Contest 3 K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /