#P1007. 独木桥
独木桥
Description
Suddenly, you receive a message from headquarters: enemy bombers are flying toward the single-plank bridge where you are located. For safety, your unit must evacuate the bridge. The bridge has length , and soldiers can only stay at positions with integer coordinates. All soldiers move at speed , and once a soldier reaches coordinate or at any moment, he leaves the bridge.
Each soldier has an initial facing direction and will walk uniformly in that direction without changing it on his own. However, if two soldiers meet face to face, they cannot pass through each other, so they both turn around and keep walking. Turning around takes no time.
Due to earlier anger, you can no longer control your soldiers. You do not even know each soldier’s initial facing direction. Therefore, you want to know the minimum possible time for your unit to completely evacuate the bridge. In addition, as headquarters is arranging to block the enemy’s advance, you also need to know the maximum possible time for your unit to completely evacuate the bridge.
Input Format
The first line contains a single integer , the length of the bridge. The coordinates on the bridge are .
The second line contains a single integer , the number of soldiers initially on the bridge.
The third line contains integers, the initial coordinate of each soldier.
Output Format
Output a single line with integers: the minimum and maximum time for the unit to evacuate the bridge. The integers are separated by a space.
4
2
1 3
2 4
Hint
For of the testdata, initially no two soldiers occupy the same coordinate, , , and the data guarantees .
Translated by ChatGPT 5
京公网安备 11011102002149号