#P3724. [AHOI2017/HNOI2017] 大佬

    ID: 1365 远端评测题 3000ms 250MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划,dp2017各省省选安徽湖南枚举,暴力

[AHOI2017/HNOI2017] 大佬

Description

People inevitably run into “dalao.” They swagger around, talking about algorithms and data structures that ordinary folks cannot grasp. Wherever they go, their presence makes others tremble and fall silent. As an OIer, you are very unhappy about this and make some disrespectful remarks. The dalao starts to take revenge on you, and you refuse to back down, vowing to bring them down. Let us explain what a dalao is: besides being a “shen niu,” a dalao also has strong self-confidence, which can be quantified by a positive integer CC. The only way to defeat a dalao is to destroy their self-confidence, i.e., make the dalao’s confidence value equal to 00 (exactly 00, not less than 00). Since you are targeted, you must prepare for nn days to contend with the dalao: during these nn days the dalao will only mock you to shake your confidence. On day n+1n+1, if the dalao finds you still unconvinced, they will crush you directly, and you will lose the ability to fight.

Your confidence can also be quantified. Let mc\mathrm{mc} be your confidence upper bound. On day ii (i1i \ge 1), the dalao taunts you once, decreasing your confidence by aia_i. If at that moment your confidence becomes less than 00, you lose the ability to fight and thus fail (note in particular that when your confidence is 00, you can still continue to fight the dalao). On that day, after the dalao’s taunt, if your confidence is still at least 00, you can and only can choose exactly one of the following actions:

  1. Talk back once. The dalao is a bit surprised, so the dalao’s confidence CC decreases by 11.
  2. Solve easy problems for a day, increasing your current confidence by wiw_i, then compare the new confidence with the upper bound mc\mathrm{mc}. If the new confidence exceeds mc\mathrm{mc}, set it to mc\mathrm{mc}. For example, if mc=50\mathrm{mc} = 50, your current confidence is 4040, and wi=5w_i = 5, then the new confidence is 4545; if wi=11w_i = 11, then the new confidence is 5050.
  3. Increase your level LL by 11.
  4. Multiply your taunt power FF by your current level LL, i.e., update FF to FLF \cdot L.
  5. Roast the dalao, decreasing the dalao’s confidence CC by FF. After roasting the dalao, your level LL automatically drops to 00, and your taunt power FF becomes 11. Since roasting the dalao costs reputation, this operation can be performed at most twice.

Pay special attention: at any time, you must not make the dalao’s confidence negative. A negative confidence value is a humiliation to the dalao, and whenever humiliated, the dalao evolves into an even stronger dalao who instantly crushes you. On day 11, before you are attacked, your confidence is full (initial confidence equals the upper bound mc\mathrm{mc}), your taunt power FF is 11, and your level LL is 00.

Since you have offended the dalao, you must prepare to confront them head-on. You know there are mm dalao in the world. Their taunting lasts nn days, and the taunt value on day ii is aia_i. No matter which dalao you face, the confidence recovery from solving easy problems on day ii is wiw_i. Among these mm dalao, exactly one will fight you (the same one for all nn days). But you need to know, for each dalao, whether you can destroy their confidence, i.e., make their confidence value exactly 00. When you fight one dalao, the others do not interfere.

Input Format

The first line contains three positive integers n,m,mcn, m, \mathrm{mc}, denoting that there are nn days and mm dalao, and your confidence upper bound is mc\mathrm{mc}.

The next line contains nn integers separated by spaces. The ii-th (1in1 \le i \le n) denotes aia_i.

The next line contains nn integers separated by spaces. The ii-th (1in1 \le i \le n) denotes wiw_i.

Then follow mm lines, each containing one positive integer. On the kk-th (1km1 \le k \le m) line, the integer CkC_k denotes the initial confidence of the kk-th dalao.

Output Format

Output mm lines. If you can defeat the kk-th dalao (make their confidence exactly 00), output 11 on the kk-th line; otherwise, output 00.

30 20 30
15 5 24 14 13 4 14 21 3 16 7 4 7 8 13 19 16 5 6 13 21 12 7 9 4 15 20 4 13 12
22 21 15 16 17 1 21 19 11 8 3 28 7 10 19 3 27 17 28 3 26 4 22 28 15 5 26 9 5 26
30
10
18
29
18
29
3
12
28
11
28
6
1
6
27
27
18
11
26
1
0
1
1
0
1
0
1
1
0
0
0
1
1
1
1
1
1
0
0
1

Hint

  • For 20%20\% of the testdata, 1n101 \le n \le 10.
  • For another 20%20\% of the testdata, 1Ci,n,mc301 \le C_i, n, \mathrm{mc} \le 30.
  • For 100%100\% of the testdata, 1n,mc1001 \le n, \mathrm{mc} \le 100, 1m201 \le m \le 20, 1ai,wimc1 \le a_i, w_i \le \mathrm{mc}, 1Ci1081 \le C_i \le 10^8.

Translated by ChatGPT 5