After completing his HSC exams, Antar decides that he has had enough of studying and wants to live a peaceful life. He moves to a quiet village in Akibland and starts his very own chicken farm.
However, Antar soon realizes that farming isn't as peaceful as he imagined.
Antar has $$$n$$$ food boxes arranged in a line. The $$$i$$$-th box contains $$$A[i]$$$ units of food.
For each of his $$$q$$$ queries, Antar wants to feed a group of $$$k$$$ chickens, where every chicken has a different appetite. He is given a ratio $$$B[1], B[2], \dots, B[k]$$$ describing how the food should be divided among these $$$k$$$ chickens.
The chickens must receive their food in order: the 1st chicken must receive its food before the 2nd, the 2nd before the 3rd, and so on. The food boxes must also be used in their original order — Antar cannot rearrange them. Therefore, all $$$n$$$ boxes must be split into $$$k$$$ contiguous, non-overlapping segments (covering every box, in order), and the $$$i$$$-th segment is given entirely to the $$$i$$$-th chicken.
Let $$$B'[i]$$$ be the total amount of food actually received by the $$$i$$$-th chicken under such a split. Antar wants this split to satisfy, for every $$$1 \le i, j \le k$$$:
$$$$$$ \frac{B'[i]}{B'[j]} = \frac{B[i]}{B[j]} $$$$$$
In other words, the food received by the chickens must be split in exactly the ratio $$$B[1] : B[2] : \dots : B[k]$$$.
For each query, determine whether such a split is possible. If it is, report where each chicken's segment ends.
Constraints
The input is read from standard input in the following format:
For each query, output:
If it is impossible to split all $$$n$$$ boxes into $$$k$$$ contiguous segments (covering all boxes, in order) whose totals are in the ratio $$$B[1] : B[2] : \dots : B[k]$$$, output the following.
If it is possible, output the following.
| Subtask | Points | $$$\boldsymbol{n}$$$ | $$$\boldsymbol{q}$$$ | $$$\boldsymbol{k}$$$ | Additional Constraints |
| 0 | 0 | – | – | – | The examples |
| 1 | 5 | $$$\le 1000$$$ | $$$=1$$$ | $$$=2$$$ | No additional constraints. |
| 2 | 10 | $$$\le 1000$$$ | – | $$$=3$$$ | $$$\sum k \le 1000$$$ |
| 3 | 15 | $$$\le 10^5$$$ | – | $$$=2$$$ | No additional constraints. |
| 4 | 30 | $$$\le 10^5$$$ | – | $$$=3$$$ | No additional constraints. |
| 5 | 40 | $$$\le 10^5$$$ | $$$\le 10^5$$$ | $$$\le n$$$ | No additional constraints. |
6 51 12 13 13 51 131 2 432 1 431 1 534 2 131 38 52
YES 2 4 6 YES 3 4 6 YES 2 3 6 NO YES 1 4 6
Consider the first query: $$$$$$ 1 : 2 : 4 $$$$$$
Antar can divide the boxes as follows:
Therefore, $$$$$$ 13 : 26 : 52 = 1 : 2 : 4. $$$$$$
So the distribution is possible, and the last box received by each chicken is:
2 4 6
Hence the answer is:
YES
2 4 6
For the fourth query ($$$4 : 2 : 1$$$), no way of splitting the $$$6$$$ boxes into $$$3$$$ contiguous, ordered segments produces totals in that exact ratio, so the answer is NO.
| Название |
|---|


