King of Hot Pot

TimeLimit:4000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
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 OK to eat at time $a_i$, and it will take Little Q $b_i$ units of time to swallow it. It is impossible for Little Q to swallow more than one dish of meat at the same moment. Note that for the $i$-th dish of meat, Little Q can choose to ignore it for a while and swallow it later.

Little Q is called "King of Hot Pot", and he wants to show off before Tangjz by swallowing $k$ dishes of meat as soon as possible. Please write a program to help Little Q find $k$ dishes of meat and the order to swallow them such that the time he spends on reaching the target is minimized for every possible value of $k$ ($1\leq k\leq n$). Note that the time for waiting is also included in the answer.
Input
The first line of the input contains a single integer $T$ ($1 \leq T \leq 10\,000$), the number of test cases.

For each case, the first line of the input 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$), denoting each dish of meat.

It is guaranteed that the sum of all $n$ is at most $1\,000\,000$.
Output
For each test case, output a single line containing $n$ integers, the $k$-th ($1\leq k\leq n$) of which denoting the minimum possible units of time needed for Little Q to swallow $k$ dishes of meat.
SampleInput
1
5
1 2
4 6
3 5
4 2
3 2
SampleOutput
3 5 7 12 18
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: