might want to pick k glasses and gather however much water in them as could reasonably be expected. With that impact you can pour water starting with one glass then onto the next however many occasions as you like. In any case, as a result of the glasses' abnormal shape (and absolutely disconnected to your regular awkwardness), each time you attempt to move any measure of water, a big part of the sum is spilled on the floor.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

You might want to pick k glasses and gather however much water in them as could reasonably be expected. With that impact you can pour water starting with one glass then onto the next however many occasions as you like. In any case, as a result of the glasses' abnormal shape (and absolutely disconnected to your regular awkwardness), each time you attempt to move any measure of water, a big part of the sum is spilled on the floor. 

 

Officially, assume a glass I at present contains ci units of water, and a glass j contains cj units of water. Assume you attempt to move x units from glass I to glass j (normally, x can not surpass ci). Then, at that point, x/2 units is spilled on the floor. After the exchange is done, the glass I will contain ci−x units, and the glass j will contain min(aj,cj+x/2) units (abundance water that doesn't fit in the glass is likewise spilled). 

 

Each time you move water, you can arbitrarlly look over which glass I to which glass j to pour, and furthermore the sum x moved can be any sure genuine number. 

 

For each k=1,… ,n, decide the biggest conceivable aggregate sum of water that can be gathered in self-assertively picked k glasses subsequent to moving water between glasses at least multiple times. 

 

Input 

 

The principal line contains a solitary integer n (1≤n≤100) — the number of glasses. 

 

The accompanying n lines depict the glasses. The I-th of these lines contains two integers man-made intelligence and bi (0≤bi≤ai≤100, ai>0) — limit, and water sum presently contained for the glass I, separately. 

 

Output 

 

Print n genuine numbers — the biggest measure of water that can be gathered in 1,… ,n glasses separately. Your answer will be acknowledged whether each number is inside 10−9 outright or relative resistance of the exact reply.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education