問題一覧 > 通常問題

No.3648 Overbooked Meeting Rooms

レベル : / AI推定難易度 : 115 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 83
作問者 : Rino-program / テスター : UT0911 gomaazarasi 👑 p-adic とある理系大学生の日常
お気に入りにしたユーザー ProblemId : 13688 / 自分の提出
問題文最終更新日: 2026-08-28 22:34:50
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
yukicoder contest 511 (Div.2) (順位表) の他の問題:

Problem Statement

There are $N$ employees and $M$ meeting rooms.
The meeting rooms are numbered $1, 2, \dots, M$.

Employee $i$ must go to meeting room $A_i$.
However, the company president, who scheduled all the meetings, made a mistake by misreading the capacities of the meeting rooms, so some employees may be unable to enter a meeting room because it is over capacity.

The capacity of meeting room $j$ is $B_j$ people. If more than $B_j$ employees try to enter that meeting room, $B_j$ of them get in and the rest cannot enter.
When all employees head to their designated meeting rooms, find the total number of employees who could not enter a meeting room.

Constraints

  • $1 \le N, M \le 500$
  • $1 \le A_i \le M$
  • $1 \le B_j \le N$
  • All input values are integers.

Input

The input is given from standard input in the following format.

$N$ $M$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_M$

Output

Output the total number of employees who could not enter a meeting room.

Print a newline at the end.

Sample

Sample 1
Input
4 3
1 2 1 1
2 1 4
Output
1

Meeting room $1$ is approached by $3$ employees, namely employees $1$, $3$, $4$, but its capacity is $2$ people, so $1$ person cannot enter.

Meeting room $2$ is approached by $1$ employee, namely employee $2$, and its capacity is $1$ person, so everyone can enter.

No one heads to meeting room $3$, and its capacity is $4$ people.

Therefore, the total number of employees who could not enter is $1 + 0 + 0 = 1$.

Sample 2
Input
3 2
1 1 1
3 3
Output
0

All meeting rooms have enough capacity, so the number of employees who could not enter is $0$.

Sample 3
Input
5 4
2 4 2 2 4
1 1 2 1
Output
3

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。