#P3724. [AHOI2017/HNOI2017] 大佬
[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 . The only way to defeat a dalao is to destroy their self-confidence, i.e., make the dalao’s confidence value equal to (exactly , not less than ). Since you are targeted, you must prepare for days to contend with the dalao: during these days the dalao will only mock you to shake your confidence. On day , 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 be your confidence upper bound. On day (), the dalao taunts you once, decreasing your confidence by . If at that moment your confidence becomes less than , you lose the ability to fight and thus fail (note in particular that when your confidence is , you can still continue to fight the dalao). On that day, after the dalao’s taunt, if your confidence is still at least , you can and only can choose exactly one of the following actions:
- Talk back once. The dalao is a bit surprised, so the dalao’s confidence decreases by .
- Solve easy problems for a day, increasing your current confidence by , then compare the new confidence with the upper bound . If the new confidence exceeds , set it to . For example, if , your current confidence is , and , then the new confidence is ; if , then the new confidence is .
- Increase your level by .
- Multiply your taunt power by your current level , i.e., update to .
- Roast the dalao, decreasing the dalao’s confidence by . After roasting the dalao, your level automatically drops to , and your taunt power becomes . 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 , before you are attacked, your confidence is full (initial confidence equals the upper bound ), your taunt power is , and your level is .
Since you have offended the dalao, you must prepare to confront them head-on. You know there are dalao in the world. Their taunting lasts days, and the taunt value on day is . No matter which dalao you face, the confidence recovery from solving easy problems on day is . Among these dalao, exactly one will fight you (the same one for all days). But you need to know, for each dalao, whether you can destroy their confidence, i.e., make their confidence value exactly . When you fight one dalao, the others do not interfere.
Input Format
The first line contains three positive integers , denoting that there are days and dalao, and your confidence upper bound is .
The next line contains integers separated by spaces. The -th () denotes .
The next line contains integers separated by spaces. The -th () denotes .
Then follow lines, each containing one positive integer. On the -th () line, the integer denotes the initial confidence of the -th dalao.
Output Format
Output lines. If you can defeat the -th dalao (make their confidence exactly ), output on the -th line; otherwise, output .
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 of the testdata, .
- For another of the testdata, .
- For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号