Answer the question
In order to leave comments, you need to log in
There are n objects on the plane, they need to be moved to the given n positions. How to do it?
There are n objects on the plane, they need to be moved to the given n positions. It doesn't matter which position which item takes. For each item, the maximum speed with which it can be moved is known, while it is possible to move all items at the same time.
Find the minimum time in which all objects can be moved to the given places.
Specifications Input
The first line contains an integer n (1 ≤ n ≤ 50).
The next n lines contain 3 integers each – the coordinates and the maximum speed of the object.
The next n lines contain 2 integers each – the coordinates of the final positions.
All coordinates are in the range from 0 to 1000, speed - from 1 to 1000.
Output data
Print one real number, the minimum time it takes to move the items. The error is not more than 10 - 4.
Answer the question
In order to leave comments, you need to log in
Well, at least you would add some saying about how you argued that it didn’t work out for you and all that.
But solve this problem for me, but I don’t want to think at all.
Come on, learn to reason already. The task is simple, apparently an Olympiad, but for some ninth or tenth graders. Although something, I remember, it was more difficult there.
Here you have 50 points. And 50 more points. Between each pair of them (and pairs of 50 squared) there is some distance. It says that the points are on a plane, which means that you were taught to count the distances between the points at school using the Pythagorean theorem.
If you know the distance between the points and know the speed of each point, then you can calculate the time.
What's left?
Well think.
This resource is not to help losers.
Perhaps your rivals in the Olympiad are now thinking for themselves, and you, a disgrace, are hacking around here.
As you have already been told, it is very easy to get a matrix of the necessary time to move each object to each point separately (divide the distance by the Pythagorean theorem by the speed of the object). Now you need to find such a minimum time that for each item you can choose a unique point, to which the travel time is not greater than the specified one.
Sort all N^2 times. Run a binary search on them. As a test, run Kuhn's algorithm to find the maximum matching if it turned out to be complete - the current bound fits or is too large. If the maximum matching is not complete, the bound is too small.
This solution is O(N^3 log N)
An alternative solution is to sort all times and add an edge corresponding to a pair of points to the graph. Look for a complementary path (depth-first search from Kuhn's algorithm). If found, expand the matching. Once the matching is complete, the last added edge is your answer. This is an O(N^4) solution. Suitable for N<50 too.
Need to know: Graphs, depth-first search, matching in bipartite graphs (Kuhn's algorithm, for example), binary search.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question