407253: GYM102726 E Headquarters

Memory Limit:256 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Headquarterstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Eric Yuan, founder and CEO of Zoom, has decided that the Zoom company headquarters in San Jose, CA is just not in an ideal location. Rent prices are rising by the day, but more importantly, Eric wants the headquarters building to have some kind of special connection to the Zoom user base, in a way that San Jose is lacking.

Eric has decided that the new headquarters building should be placed at the site of the average location of all Zoom users. That way the company can be symbolically placed at the center of its users' lives. Of course, if he truly wanted to follow through with this idea, the building would need to be built somewhere beneath the Earth's crust. But to make his vision feasible in reality, Eric has decided to simplify his model of the world to just consider 2D locations on a flat map.

Given a list of $$$N$$$ cities, each with a location ($$$x_i, y_i$$$) on the map and a population of Zoom users $$$p_i$$$ concentrated in that city, help Eric figure out where to build the new Zoom headquarters!

Input

The first line of input contains the integer $$$N$$$ ($$$1\leq N < 1000$$$). The next $$$N$$$ lines each consist of three integers: $$$x_i$$$, $$$y_i$$$ where ($$$-1000\leq x_i, y_i\leq 1000$$$), and $$$p_i$$$ where ($$$1\leq p_i < 1000$$$), denoting the coordinate location and user population (in thousands) of the $$$i^{th}$$$ city.

Output

Output the average location of all Zoom users, $$$x_a$$$ and $$$y_a$$$, within a $$$.0001$$$ margin of error. Assume that all Zoom users live exactly at the ($$$x,y$$$) location of their home city.

ExampleInput
3
-10 6 4
1 -9 3
8 8 3
Output
-1.3 2.1

加入题单

上一题 下一题 算法标签: