問題一覧 > 通常問題

No.2422 regisys?

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 53
作問者 : dyktr_06 / テスター : Nafmo2 LaFolia13 hikikomori sepa38 Udon ryota2357
お気に入りにしたユーザー ProblemId : 9705 / 自分の提出
問題文最終更新日: 2023-08-12 13:41:48
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
MMA Contest 016 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。