#P13848. [CERC 2023] Drying Laundry
[CERC 2023] Drying Laundry
题目描述
Harry the Beaver runs a hotel and has to wash bed sheets every Sunday night for the next weeks until the tourist season ends. On week , he has freshly washed bed sheets that he wants to dry by hanging them on two parallel clotheslines of length each. The sheets can be hung next to each other but must not overlap. Each sheet is units wide and rather long, therefore he will always orient it so that it will take up units of the line when hung to dry. The sheets have different drying times that are not related to their sizes because of different materials. Thus, the -th sheet needs minutes to dry. However, if it is hung over both lines at the same time, it dries quicker in minutes, but also takes up space on the other line. To avoid smelly sheets, Harry the Beaver has to start drying all of them immediately after washing, i.e. all sheets have to be hung simultaneously.
Harry the Beaver wants to go to sleep as soon as possible on Sundays, therefore, he asks you to help him determine the minimal required drying time for each week , or inform him that it is impossible to finish drying the sheets that week.
输入格式
The first line contains an integer , the number of sheets, and an integer , the number of weeks until the end of the tourist season. The next lines contain space-separated integers , , and , which correspond to the width, the shorter drying time, and the longer drying time of the -th sheet, respectively. The final lines the the input contain integers , -th of which represents the length of the clothesline for week .
输出格式
Print lines, with -th of them containing the minimal required drying time for week , or "-1" (without the quotes) if it is impossible to finish drying the sheets that week.
3 3
1 2 2
1 1 4
2 3 100
3
1
4
4
-1
3
提示
Input limits
- for all
- $1 \leq t_i^{\text{fast}} \leq t_i^{\text{slow}} \leq 10^9$ for all
- for all