#P4602. [CTSC2018] 混合果汁
[CTSC2018] 混合果汁
Description
Little R is obsessed with making “dark cuisine”, especially mixed juice.
There are kinds of juice in the store, numbered . The deliciousness of juice is , and its price per liter is . When making mixed juice, Little R also has some special rules: in a bottle of mixed juice, juice can be added at most liters.
Now children come to Little R for mixed juice. They all want Little R to use the juices in the store to make a bottle of mixed juice for them. For the -th child, they want the total price of the mixed juice to be no more than , and the volume to be at least . Under these constraints, the children also hope the deliciousness of the mixed juice is as high as possible. The deliciousness of a bottle of mixed juice equals the minimum deliciousness among all juices that participate in the mixture. Please compute the highest deliciousness each child can get.
Input Format
The first line contains two positive integers , the number of kinds of juice and the number of children.
The next lines each contain three positive integers , meaning the deliciousness of juice is , its price per liter is , and its addition limit in one bottle is liters.
The next lines describe all children: each line contains two positive integers , meaning the -th child can pay at most yuan, and wants at least liters of juice.
Output Format
For all children in order, output one line for each child containing an integer, the highest deliciousness of the mixed juice they can drink. If their request cannot be satisfied, output .
3 4
1 3 5
2 1 3
3 2 5
6 3
5 3
10 10
20 10
3
2
-1
1
Hint
For all testdata, it is guaranteed that , , .
| 测试点编号 | 其他限制 | ||
|---|---|---|---|
| None | |||
| None | |||
Translated by ChatGPT 5
京公网安备 11011102002149号