| UTPC Spring 2026 Open Contest |
|---|
| Finished |
Oh glorious King Wu, please guide us towards the full-solve...
Kimmy is very obsessed with Cosmo, so he got inspired to hop in a rocket and explore the cosmos for himself. He's fascinated by the many moons orbiting Jupiter during his time there, and makes note of both their distances and the potential they hold. Kimmy realizes how critical his observations are for exploring other spatial bodies, so he develops the Kimmy metric to hopefully optimize space research. For a list $$$a$$$ of $$$n$$$ moons, where the $$$i$$$th moon has scientific potential $$$p_i$$$ and is $$$d_i$$$ meters away, the metric $$$k$$$ is defined as
$$$$$$k = \frac{(\sum_i p_i)^2}{\sum_i d_i}$$$$$$
Since space exploration resources are limited, Kimmy wants to figure out how to pick the best moons to visit. Can you help him find the highest metric he can reach by exploring a subarray of moons?
The first line contains $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$), the number of moons. The second line contains $$$n$$$ space-separated integers, denoting the array $$$p$$$ ($$$1 \le p_i \le 10^9$$$). The third line contains $$$n$$$ space-separated integers, denoting the array $$$d$$$ ($$$1 \le d_i \le 10^9$$$).
Output a single value $$$k$$$: the maximum Kimmy metric among all (non-empty) subarrays of the set of moons. Your answer will be correct if its relative or absolute error does not exceed $$$10^{-6}$$$.
3 5 15 10 6 3 2
125
5 10 13 7 8 11 11 7 14 17 19
35.30882353
In the first test case, the subarray consisting of the second and third moons achieves a Kimmy metric of $$$$$$\frac{(15+10)^2}{3+2} = 125.$$$$$$ It can be shown no higher metric can be reached.
| Name |
|---|


