| Innopolis Open 2024. Final round |
|---|
| Finished |
Cat Miston started downloading the series "Police Cat". The series consists of $$$n$$$ episodes, where the $$$i$$$-th episode is currently being downloaded at a speed of $$$v_i$$$ and the browser indicates that the $$$i$$$-th episode will be downloaded exactly in $$$t_i$$$ minutes, which is not entirely true.
The browser calculates the time based on the assumption that the download speed of the $$$i$$$-th episode will not change. However, when a certain episode is completely downloaded, the download speed of other episodes increases (there are no other reasons for changes in the download speed of any episode). At the same time, the ratios of download speeds of the remaining episodes remain unchanged. In other words, if $$$v_i^t$$$ is the download speed of the $$$i$$$-th episode at time $$$t$$$, then for any $$$i$$$ and $$$j$$$ it holds that for all $$$t$$$ less than the moment of download completion of the $$$i$$$-th or $$$j$$$-th episode the value of $$$\frac{v_i^t}{v_j^t}$$$ is the same.
There is no other network load besides downloading the $$$n$$$ episodes. In other words, the total download speed $$$\sum\limits_{i=1}^n v_i^t$$$ is constant (the same at any moment $$$t$$$).
Determine the actual time at which each episode will be fully downloaded.
The first line of input contains an integer $$$n$$$ — the number of episodes in the series ($$$1 \le n \le 3 \cdot 10^5$$$).
Each of the following $$$n$$$ lines contains two integers $$$v_i$$$ and $$$t_i$$$ — the current download speed and the download time assumed by the browser for the $$$i$$$-th episode ($$$1 \le v_i, t_i \le 10^{18}$$$; $$$\sum\limits_{i=1}^n v_i \le 10^{18}$$$).
For each episode output the actual time it will take to download it.
Your answer will be accepted if its absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$ and the jury's answer be $$$b$$$. Your answer will be accepted if $$$\frac {|a - b|}{\max(1, b)} \le 10^{-6}$$$.
Points for each subtask are awarded only if all tests for that subtask and the necessary subtasks are successfully passed.
| Subtask | Points | Constraints | Required subtasks | Feedback policy |
| 0 | – | examples | full | |
| 1 | 5 | $$$n \le 2$$$ | full | |
| 2 | 5 | $$$n \le 3$$$ | 0, 1 | first error |
| 3 | 15 | $$$n, v_i, t_i \le 3000$$$ | 0 | first error |
| 4 | 20 | $$$n \le 3000$$$ | 0 – 3 | first error |
| 5 | 20 | $$$v_i = v_j$$$ for all $$$i$$$, $$$j$$$ | first error | |
| 6 | 15 | $$$n \le 30\,000$$$ | 0 – 4 | first error |
| 7 | 5 | $$$t_i \le 10^{9}$$$ for all $$$i$$$; $$$\sum\limits_{i=1}^n v_i \le 10^{9}$$$ | 0, 3 | first error |
| 8 | 15 | no additional constraints | 0 – 7 | first error |
22 43 5
4 4.6
31 45 22 3
2.5 2 2.375
| Name |
|---|


