P4475 Chocolate Kingdom
Description
In the Chocolate Kingdom, chocolates are made from milk and cocoa. However, not every piece of chocolate is favored by the people, because no one likes overly sweet chocolate.
For each piece of chocolate, let $x$ and $y$ be its milk and cocoa content. Since everyone has their own standard for sweetness, each person has two parameters $a$ and $b$, which are their weights for milk and cocoa, respectively. Therefore, for a chocolate with milk and cocoa content $x$ and $y$, its sweetness for that person is $ax+by$. Each person also has a sweetness threshold $c$: all chocolates with sweetness greater than or equal to $c$ are unacceptable to them. Each piece of chocolate has a deliciousness value $h$.
Now we want to know, for each person, the sum of the deliciousness values of the chocolates they can accept.
Input Format
The first line contains two positive integers $n$ and $m$, denoting the number of chocolates and the number of queries.
The next $n$ lines each contain three integers $x , y , h$, as described above.
Then the next $m$ lines each contain three integers $a , b , c$, as described above.
Output Format
Output $m$ lines, where the $i$-th line is the sum of the deliciousness values of the chocolates acceptable to the $i$-th person.
Explanation/Hint
Constraints: For 100% of the testdata, $1