No.3648 Overbooked Meeting Rooms
タグ : / 解いたユーザー数 83
作問者 :
UT0911
とある理系大学生の日常
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もしくは右上の雲マークをクリックしてアカウントを作成してください。