#P3592. [POI 2015 R3] 洗车 Car washes
[POI 2015 R3] 洗车 Car washes
Description
There are car wash shops arranged in a row from left to right. Each shop has a positive integer price . There are customers. The -th customer will drive past shops from the -th to the -th, inclusive, and will choose the cheapest shop among these to buy one wash. However, if this cheapest price is greater than , then this person does not buy a wash. Assign a price to each shop so that the total amount spent by all customers is maximized.
Input Format
The first line contains two positive integers (, ).
The next lines each contain three positive integers (, ).
Output Format
On the first line, output a single positive integer — the maximum total spending.
On the second line, output positive integers, representing the prices of each shop from left to right, with . If there are multiple optimal solutions, output any of them.
7 5
1 4 7
3 7 13
5 6 20
6 7 1
1 2 5
43
5 5 13 13 20 20 13
Hint
Original title: Myjnie.
Translated by ChatGPT 5
京公网安备 11011102002149号