# TopCoder

\begin{align} AC \times 2^9 \\ \text{New TIOJ ?} \end{align}

46.2% (6/13)

22.2% (16/72)

# Input Format

$1 \leq k \leq n \leq 10 ^ 6$
$0 \leq b_i < i, \forall i \in [1, n]$
$0 \leq a_i \leq 10 ^ 6, \forall i \in [0, n]$
$0 \leq m_i \leq 10 ^ 6, \forall i \in [1, n]$

5 3
0 0 0 0 0 0
0 1 0 3 3
3 5 2 4 6

39

7 3
4 2 8 3 9 1 5 2
0 1 2 1 3 4 6
5 0 8 2 4 9 7

87

# Problem Source

No. Testdata Range Constraints Score
1 0~3 $\forall 0 \leq i \leq n, a_i = 0, k \leq 10$ 3
2 4~7 $\forall 0 \leq i \leq n, a_i = 0, \forall 1 \leq i \leq n, b_i = i - 1$ 15
3 0~11 $\forall 0 \leq i \leq n, a_i = 0$ 20
4 12~15 $n \leq 10 ^ 5$ 36
5 0~22 無其他限制 26

# Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 3000 524188 65536 1 3 5
1 3000 524188 65536 1 3 5
2 3000 524188 65536 1 3 5
3 3000 524188 65536 1 3 5
4 3000 524188 65536 2 3 5
5 3000 524188 65536 2 3 5
6 3000 524188 65536 2 3 5
7 3000 524188 65536 2 3 5
8 3000 524188 65536 3 5
9 3000 524188 65536 3 5
10 3000 524188 65536 3 5
11 3000 524188 65536 3 5
12 3000 524188 65536 4 5
13 3000 524188 65536 4 5
14 3000 524188 65536 4 5
15 3000 524188 65536 4 5
16 3000 524188 65536 5
17 3000 524188 65536 5
18 3000 524188 65536 5
19 3000 524188 65536 5
20 3000 524188 65536 5
21 3000 524188 65536 5
22 3000 524188 65536 5