QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#476. Warehouse

统计

The streets of the New Byte City form a rectangular grid - those running east-west are simply called streets, while those running north-south are called avenues. To avoid mistakes, we shall call them h-streets and v-streets, respectively. The v-streets are numbered from $1$ to $500\,000\,000$ eastwards. Similarly, the h-streets are numbered from $1$ to $500\,000\,000$ northwards. Every v-street crosses every h-street and, conversely, every h-street crosses every v-street. The distance between two consecutive v-streets, as well as between two consecutive h-streets, is exactly one kilometre.

problem_476_1.gif

There are $k$ shops in the city, each one of them is situated at a crossroads. Byteasar, the merchant, supplies every single one of the $k$ shops, and furthermore he returns to some of them several times a day with fresh supplies. Recently he has decided to have a warehouse built, from which the goods would be delivered. For obvious reasons, it should stand at a crossroads. The lorry loaded with goods can supply only one shop per course - it leaves the warehouse, delivers to the shop and returns to the warehouse. The lorry always picks the shortest path from the warehouse to the shop, and the shortest one back (possibly the same one). The distance between points $(x_i,y_i)$ and $(x_j,y_j)$ equals $\max\{|x_i-x_j|,|y_i-y_j|\}$.

Task

Write a programme that:

  • reads the locations of shops, as well as the numbers of their daily deliveries, from the standard input
  • determines such a warehouse's position that the summary distance of the lorry's daily route is minimal,
  • writes the result to the standard output.

Input

The first line of the standard input contains one integer $n$ ($1 ≤ n ≤ 100\,000$), the number of shops in the New Byte City.

The following $n$ lines contain the shops' descriptions. The $(i+1)$’th line contains three integers $x_i$, $y_i$ and $t_i$ ($1 ≤ x_i,y_i ≤ 500\,000\,000$, $1 ≤ t_i ≤ 1\,000\,000$), separated by single spaces. This triple means that the 'th shop lies at the crossing of xi’th v-street and yi’th h-street and the lorry delivers goods to this shop ti times a day.

Output

The first and only line of the standard output should contain two integers $x_m$ and $y_m$, separated by a single space, denoting the optimal position of the warehouse as the crossroads of the $x_m$’th v-street and the $y_m$’th h-street. Should there be many optimal solutions, your programme is to pick one of them arbitrarily.

Example

Input

3
2 2 1
6 2 1
4 6 1

Output

4 4

Hints

The picture below illustrates the example. The numbered points are the shops. The point is the optimal position of the warehouse.

problem_476_2.gif
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.