| Codeforces Round 1113 (Div. 2) |
|---|
| Finished |
Alisa has a shopping card with an initial balance of $$$h$$$. There are $$$n$$$ types of products in a supermarket. A product of type $$$i$$$ costs $$$c_i$$$, and Alisa can buy any number of products of each type.
There are also $$$m$$$ rebate activities. The $$$j$$$-th activity applies to a purchase if its total cost is at least $$$a_j$$$ and gives a rebate of $$$b_j$$$.
For each purchase, Alisa performs the following operations:
For every $$$h$$$ from $$$1$$$ to $$$s$$$, determine whether Alisa can make the balance on her card equal to $$$0$$$ after finitely many purchases.
The first line contains three integers $$$n$$$, $$$m$$$, and $$$s$$$ ($$$1 \le n, m, s \le 125\,000$$$) — the number of product types, the number of rebate activities, and the maximum initial balance to consider, respectively.
The second line contains $$$n$$$ integers $$$c_1, c_2, \ldots, c_n$$$ ($$$1 \le c_i \le 125\,000$$$) — the price of a product of each type.
The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le a_i, b_i \le 125\,000$$$) — the spending threshold and the rebate of the $$$i$$$-th activity, respectively.
It is guaranteed that $$$a_1 \lt a_2 \lt \cdots \lt a_m$$$ and $$$b_1 \lt b_2 \lt \cdots \lt b_m$$$.
Print $$$s$$$ lines. For each $$$i$$$ ($$$1 \le i \le s$$$), print "YES" if Alisa can make the balance on her card equal to $$$0$$$ when its initial balance is $$$i$$$, and print "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
2 1 154 78 4
NO NO NO YES NO NO YES YES NO NO YES YES NO YES YES
5 3 254 8 12 16 206 87 98 10
NO NO NO YES NO NO NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO
In the first example, Alisa can make the balance equal to $$$0$$$ when the initial balance is $$$15$$$ as follows:
Therefore, the $$$15$$$-th line of the first example output is "YES".
In the second example, if the initial balance is $$$4$$$, Alisa can buy one product of the first type for $$$4$$$. Since $$$4 \lt 6$$$, no rebate activity applies, and the balance becomes $$$0$$$. Therefore, the fourth line of the second example output is "YES". If the initial balance is $$$1$$$, no product is affordable, so the first line is "NO".
| Name |
|---|


