#P4754. True Vegetable

    ID: 3608 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>模拟贪心O2优化概率论,统计洛谷月赛

True Vegetable

Description

Little A now has NN problems, numbered 1,2,,N1,2,\cdots,N. The initial “toxicity level” of each problem is 00 or 11. In each round, Little A can increase the toxicity level of KK problems with consecutive indices by 11.

However, Little B is not very strong and does not really want Little A to create toxic problems. At the start of round wiw_i, Little B can spread viv_i points of “noob gas” to problem xix_i, which decreases the toxicity level of problem xix_i by viv_i points (it may become negative after decreasing). We assume the amount of “noob gas” is limited: after releasing viv_i points of noob gas, Little B must wait at least rvir_{v_i} 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 11.

Input Format

The first line contains four integers N,M,K,LN,M,K,L, 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 NN integers a1,a2,,aNa_1,a_2,\cdots,a_N, representing the toxicity levels of the NN problems.

The third line contains LL integers r1,r2,,rLr_1,r_2,\cdots,r_L, representing the cooldown rounds for releasing 11 to LL points of noob gas.

The next MM lines each contain three integers wi,xi,viw_i,x_i,v_i, meaning that at the start of round wiw_i, Little B releases viv_i points of noob gas to problem xix_i. It is guaranteed that {wi}\{w_i\} 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 11.

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

1N,M5×1051 \le N,M \le 5 \times 10^5.

1KN1 \le K \le N.

1L1001 \le L \le 100.

a[i]{0,1}a[i] \in \{0,1\}.

1=r1<r2<<rL2×L1 = r_1 < r_2 < \cdots < r_L \le 2 \times L.

1wiN+L1 \le w_i \le N+L.

wi+rviwi+1w_i+r_{v_i} \le w_{i+1}.

1xiN1 \le x_i \le N.

1viL1 \le v_i \le L.

Translated by ChatGPT 5