| ZCO 2024 |
|---|
| Finished |
You are a farmer, and you want to grow a wide variety of vegetables so that the people in your town can eat a balanced diet.
In order to remain healthy, a person must eat a diet that contains $$$N$$$ essential vegetables, numbered from $$$1$$$ to $$$N$$$. In total, your town requires $$$A_i$$$ units of each vegetable $$$i$$$, for $$$1 \leq i \leq N$$$. In order to grow a single unit of vegetable $$$i$$$, you require $$$B_i$$$ units of water.
However, you can use upgrades to improve the efficiency of your farm. In a single upgrade, you can do one of the following two actions:
You wish to answer $$$Q$$$ questions numbered from $$$1$$$ to $$$Q$$$, where the $$$j$$$-th question is the following:
The first line contains two space-separated integers $$$N$$$ and $$$Q$$$, the number of essential vegetables and the number of questions, respectively.
The second line contains $$$N$$$ space separated integers, $$$A_1$$$, $$$A_2$$$, $$$...$$$ $$$A_N$$$.
The third line contains $$$N$$$ space separated integers, $$$B_1$$$, $$$B_2$$$, $$$...$$$ $$$B_N$$$.
The following $$$Q$$$ lines describe the questions. The $$$j$$$-th of these lines contains a single integer $$$X_j$$$.
You should print $$$Q$$$ lines of output. The $$$j$$$-th line should be the answer to the $$$j$$$-th question.
The test data for this problem is divided into multiple subtasks. In order to pass a subtask, your submitted program must solve every test case within that subtask correctly and within the time and memory limits.
You will be awarded the points allocated to a subtask if at least one submission you make during the contest passes that subtask. You do not need to combine your solutions for multiple subtasks into a single submission.
Please keep in mind that the subtasks are not necessarily arranged in increasing order of difficulty. We encourage you to try as many subtasks as possible.
Constraints
In all test data, it is guaranteed that:
Please be aware that the output for this problem may not fit in 32-bit integers. You may need to use 64-bit integers in your computations.
Subtasks
4 22 4 5 35 2 3 312
37 32
4 11 4 2 35 4 3 629
0
14 41 1 1 1 1 1 1 1 1 1 1 1 1 14 2 4 12 10 5 2 6 4 10 2 3 5 123956
47 13 31 26
8 67 9 4 2 2 2 7 71 10 6 7 4 6 8 42931227819
8 209 125 20 159 72
1 1100000010000001
999999000000
In example 1, there are two operations.
Example 1 is valid for subtasks 2, 5, 6, 7, 8, 9 and 10.
In example 2, there is only one operation. You are allowed up to $$$29$$$ upgrades, which is sufficient to make the final array $$$A$$$ and the final array $$$B$$$ both $$$[0, 0, 0, 0]$$$. This yields a water requirement of $$$0$$$ units.
Example 2 is valid for subtasks 5, 6, 7, 8, 9 and 10.
Example 3 is valid for subtasks 3, 4, 5, 6, 7, 8, 9 and 10.
Example 4 is valid for subtasks 5, 6, 7, 8, 9 and 10.
Example 5 is valid for subtasks 2, 5, 6, 7, 8, 9 and 10.
| Name |
|---|


