#P7688. [CEOI 2005] Ticket Office
[CEOI 2005] Ticket Office
Description
The ticket office sells concert tickets, but it does not sell tickets for single seats. Instead, it sells group tickets for a fixed number of consecutive seats. The office has received a large number of purchase orders. A purchase order for a group of seats specifies the smallest seat number in that group. The office may not be able to fulfill all purchase orders. Also, if it assigns seats strictly according to the purchase orders, many seats may remain empty. Therefore, the office uses the following allocation and pricing strategy. If a purchase order is accepted and the assigned seats are exactly the requested seats, then the buyer pays full price ( petaks). If a purchase order is accepted but the assigned seats differ from the requested seats (in at least one position), then the buyer pays half price ( petak). The goal is to maximize the total revenue.
Please write a program to compute the maximum revenue that can be achieved, and assign seats to the selected orders to achieve this revenue.
Input Format
The first line contains two integers, and . is the number of seats, and is the number of consecutive seats in each group. Seat numbers range from to . The second line contains an integer , the number of purchase orders. The third line contains integers defining the purchase orders. The -th number in this line means that the -th buyer requests a group of seats starting from seat and ending at seat .
Output Format
The first line contains an integer , the maximum revenue. The second line contains an integer , the number of accepted orders. The next lines describe the seat assignments. Each line contains a pair of integers . The pair means that buyer receives seats starting from seat number . These lines must be sorted in increasing order of seat number.
20 3
7
4 2 10 9 16 15 17
9
6
4 1
1 4
2 7
3 10
6 13
5 16
Hint
Constraints
For of the testdata, , , , .
Notes
From Ticket Office, CENTRAL-EUROPEAN OLYMPIAD IN INFORMATICS 2005.
Translated and整理 (zhengli) by
Translated by ChatGPT 5
京公网安备 11011102002149号