CF1458B.Glass Half Spilled
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n glasses on the table numbered 1,…,n . The glass i can hold up to ai units of water, and currently contains bi units of water.
You would like to choose k glasses and collect as much water in them as possible. To that effect you can pour water from one glass to another as many times as you like. However, because of the glasses' awkward shape (and totally unrelated to your natural clumsiness), each time you try to transfer any amount of water, half of the amount is spilled on the floor.
Formally, suppose a glass i currently contains ci units of water, and a glass j contains cj units of water. Suppose you try to transfer x units from glass i to glass j (naturally, x can not exceed ci ). Then, x/2 units is spilled on the floor. After the transfer is done, the glass i will contain ci−x units, and the glass j will contain min(aj,cj+x/2) units (excess water that doesn't fit in the glass is also spilled).
Each time you transfer water, you can arbitrarlly choose from which glass i to which glass j to pour, and also the amount x transferred can be any positive real number.
For each k=1,…,n , determine the largest possible total amount of water that can be collected in arbitrarily chosen k glasses after transferring water between glasses zero or more times.
输入格式
The first line contains a single integer n ( 1≤n≤100 ) — the number of glasses.
The following n lines describe the glasses. The i -th of these lines contains two integers ai and bi ( 0≤bi≤ai≤100 , ai>0 ) — capacity, and water amount currently contained for the glass i , respectively.
输出格式
Print n real numbers — the largest amount of water that can be collected in 1,…,n glasses respectively. Your answer will be accepted if each number is within 10−9 absolute or relative tolerance of the precise answer.
输入输出样例
输入#1
3 6 5 6 5 10 2
输出#1
7.0000000000 11.0000000000 12.0000000000
说明/提示
In the sample case, you can act as follows:
- for k=1 , transfer water from the first two glasses to the third one, spilling (5+5)/2=5 units and securing 2+(5+5)/2=7 units;
- for k=2 , transfer water from the third glass to any of the first two, spilling 2/2=1 unit and securing 5+5+2/2=11 units;
- for k=3 , do nothing. All 5+5+2=12 units are secured.