Conference Rides
InterviewTime limit1sMemory limit2048 MB
Assign each carless attendee to one driver so that the time until every attendee reaches home is minimized.
- Level
Medium5 of 10
- Topics
- Binary search, Graph
- Solved
- No attempts yet
Problem
There are attendees at a conference, numbered through . Each of the first attendees (numbered through ) has a car to drive home after the event. The remaining attendees have no car and must get a ride home from the first attendees. Each attendee with a car can pick up at most one other attendee from attendees through , drive them home, and then drive to their own home.
You are given a distance matrix of size covering the attendees' homes and the conference hall. For , location is the home of attendee , and location is the conference hall. is the estimated travel time from location to location .
Assign drivers to passengers so that the time until every attendee has reached home is minimized.
Input
The input starts with a line containing two integers and (, ). It is guaranteed that .
The next lines each contain integers. The th number on the th line is (). for all , and for all , , . is not necessarily symmetric.
Output
On the first line, print the minimum time until all attendees have arrived home.
On each of the next lines, print a non-negative integer for . If , attendee drives directly home without picking anyone up. If , attendee picks up attendee , drives them home, and then drives home. Each attendee without a car must be picked up by exactly one car.