The war has entered a critical time. You are the leader of the transport team, leading the transport force to deliver supplies to the front. The transportation task is as boring as a problem. You want to find some excitement, so you order your soldiers to admire the scenery on a log bridge in front, and you stay under the bridge to admire the soldiers. The soldiers were very angry because the single-plank bridge was very narrow and could only accommodate one person. If there are two people walking towards each other on the bridge to meet, then the two of them will not be able to bypass each other, and only one person can turn back and get off the bridge and let the other person pass first. However, multiple people can stay in the same location at the same time.
Suddenly, you received a message from the command center that enemy bombers are flying towards the single-plank bridge where you are! To be safe, your troops must withdraw the log bridge. The length of the single-plank bridge is , and soldiers can only stay where the coordinates are integers. The speed of all soldiers is , but a soldier arrives at a position with coordinates or at a certain moment, and he leaves the single-plank bridge.
Each soldier has an initial facing direction, they will walk in this direction at a constant speed, and will not change direction by themselves. However, if two soldiers meet face to face, they cannot pass each other, so they turn around and continue walking . It doesn't take any time to turn around.
Because of the previous anger, you can no longer control your soldiers. Even, you don't even know the direction each soldier is facing initially. Therefore, you want to know how long it takes at least for your troops to evacuate the log bridge. In addition, the headquarters is also arranging to stop the enemy's attack, so you also need to know how long it takes at most for your troops to evacuate the log bridge.
How to submit:
The pastebin below has inputs. Each input has the format:
Line 1: An integer , the length of the log bridge, where the coordinates are .
Line 2: An integer , the number of soldiers.
Line 3: integers, the initial coordinates for each soldier.
Output: Two integers . is the minimum time it takes for your troops to evacuate the log bridge, is the maximum time it takes for your troops to evacuate the log bridge.
Then submit the sum of of each output.
Input restrictions:
No two soldiers are on the same coordinate initially.
.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
No explanations have been posted yet. Check back later!