No.2422 regisys?
Problem Statement
At MMA's junk market, $N$ types of items are on sale, with $1$ item of each type.
The item of type $i \: (1 \leq i \leq N)$ can be purchased for $A_i$ yen by a member of the general public and for $B_i$ yen by an MMA member.
There are also $M$ buyers. Buyer $j \: (1 \leq j \leq M)$ has attribute $T_j$ and holds $C_j$ yen.
Here, $T_j = 0$ denotes a member of the general public and $T_j = 1$ denotes an MMA member.
Each buyer can purchase, only $1$ time, any one item at the junk market that they can afford with the money they hold. (They do not have to purchase anything.)
Find the minimum possible number of types of items left unsold.
Constraints
- $1 \leq N, M \leq 2 \times 10^5$
- $1 \leq A_i, B_i \leq 10^{9}$
- $T_j$ is $0$ or $1$
- $1 \leq C_j \leq 10^{9}$
- All input values are integers.
Input
The input is given from standard input in the following format.
$N$ $M$ $A_1$ $A_2$ ... $A_N$ $B_1$ $B_2$ ... $B_N$ $T_1$ $C_1$ $T_2$ $C_2$ $\vdots$ $T_M$ $C_M$
Output
Output the answer to the problem on one line.
Sample
Sample 1
Input
5 5 100 200 300 400 500 150 100 250 400 600 0 50 0 100 0 450 1 200 1 300
Output
1
The number of types of items left unsold can be made $1$ type as follows.
- Buyer $1$ purchases nothing.
- Buyer $2$ purchases item $1$.
- Buyer $3$ purchases item $4$.
- Buyer $4$ purchases item $2$.
- Buyer $5$ purchases item $3$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
LaFolia13
hikikomori
sepa38