#P4754. True Vegetable
True Vegetable
Description
Little A now has problems, numbered . The initial “toxicity level” of each problem is or . In each round, Little A can increase the toxicity level of problems with consecutive indices by .
However, Little B is not very strong and does not really want Little A to create toxic problems. At the start of round , Little B can spread points of “noob gas” to problem , which decreases the toxicity level of problem by points (it may become negative after decreasing). We assume the amount of “noob gas” is limited: after releasing points of noob gas, Little B must wait at least rounds before being able to release noob gas again.
Now Little A knows Little B’s plan for releasing noob gas, and he wants to know the minimum number of rounds needed to make the toxicity level of every problem at least .
Input Format
The first line contains four integers , representing the number of problems, the number of Little B’s operations, the number of consecutive problems increased each time, and the maximum value of noob gas that can be released.
The second line contains integers , representing the toxicity levels of the problems.
The third line contains integers , representing the cooldown rounds for releasing to points of noob gas.
The next lines each contain three integers , meaning that at the start of round , Little B releases points of noob gas to problem . It is guaranteed that is a strictly increasing sequence.
Output Format
Output the minimum number of rounds Little A needs to make the toxicity level of every problem at least .
6 1 3 2
0 0 0 0 0 0
1 2
2 1 1
3
6 1 3 2
1 0 0 0 0 0
1 2
2 1 1
2
6 1 6 2
0 0 0 0 0 0
1 2
2 1 1
1
Hint
Constraints
.
.
.
.
.
.
.
.
.
Translated by ChatGPT 5
京公网安备 11011102002149号