103501: [Atcoder]ABC350 B - Dentist Aoki

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:7 Solved:0

Description

Score: $200$ points

Problem Statement

Takahashi has $N$ teeth, one in each of the holes numbered $1, 2, \dots, N$.
Dentist Aoki will perform $Q$ treatments on these teeth and holes.
In the $i$-th treatment, hole $T_i$ is treated as follows:

  • If there is a tooth in hole $T_i$, remove the tooth from hole $T_i$.
  • If there is no tooth in hole $T_i$ (i.e., the hole is empty), grow a tooth in hole $T_i$.

After all treatments are completed, how many teeth does Takahashi have?

Constraints

  • All input values are integers.
  • $1 \le N, Q \le 1000$
  • $1 \le T_i \le N$

Input

The input is given from Standard Input in the following format:

$N$ $Q$
$T_1$ $T_2$ $\dots$ $T_Q$

Output

Print the number of teeth as an integer.


Sample Input 1

30 6
2 9 18 27 18 9

Sample Output 1

28

Initially, Takahashi has $30$ teeth, and Aoki performs six treatments.

  • In the first treatment, hole $2$ is treated. There is a tooth in hole $2$, so it is removed.
  • In the second treatment, hole $9$ is treated. There is a tooth in hole $9$, so it is removed.
  • In the third treatment, hole $18$ is treated. There is a tooth in hole $18$, so it is removed.
  • In the fourth treatment, hole $27$ is treated. There is a tooth in hole $27$, so it is removed.
  • In the fifth treatment, hole $18$ is treated. There is no tooth in hole $18$, so a tooth is grown.
  • In the sixth treatment, hole $9$ is treated. There is no tooth in hole $9$, so a tooth is grown.

The final count of teeth is $28$.


Sample Input 2

1 7
1 1 1 1 1 1 1

Sample Output 2

0

Sample Input 3

9 20
9 5 1 2 2 2 8 9 2 1 6 2 6 5 8 7 8 5 9 8

Sample Output 3

5

Input

Output

得分:200分

问题描述

高桥有 $N$ 颗牙齿,分别位于编号为 $1, 2, \dots, N$ 的位置。
牙医青木将对这些牙齿和位置进行 $Q$ 次治疗。
在第 $i$ 次治疗中,位置 $T_i$ 将按照以下方式进行处理:

  • 如果位置 $T_i$ 有牙齿,那么将牙齿从位置 $T_i$ 移除。
  • 如果位置 $T_i$ 没有牙齿(即,位置为空),则在位置 $T_i$ 生长一颗牙齿。

所有治疗完成后,高桥会有多少颗牙齿呢?

约束

  • 所有输入值都是整数。
  • $1 \le N, Q \le 1000$
  • $1 \le T_i \le N$

输入

输入数据从标准输入按以下格式给出:

$N$ $Q$
$T_1$ $T_2$ $\dots$ $T_Q$

输出

打印一个整数,表示牙齿的数量。


样例输入1

30 6
2 9 18 27 18 9

样例输出1

28

起初,高桥有 $30$ 颗牙齿,青木进行了六次治疗。

  • 第一次治疗,处理位置 $2$。位置 $2$ 有牙齿,所以移除。
  • 第二次治疗,处理位置 $9$。位置 $9$ 有牙齿,所以移除。
  • 第三次治疗,处理位置 $18$。位置 $18$ 有牙齿,所以移除。
  • 第四次治疗,处理位置 $27$。位置 $27$ 有牙齿,所以移除。
  • 第五次治疗,处理位置 $18$。位置 $18$ 没有牙齿,所以生长一颗牙齿。
  • 第六次治疗,处理位置 $9$。位置 $9$ 没有牙齿,所以生长一颗牙齿。

最后的牙齿数量为 $28$ 颗。


样例输入2

1 7
1 1 1 1 1 1 1

样例输出2

0

样例输入3

9 20
9 5 1 2 2 2 8 9 2 1 6 2 6 5 8 7 8 5 9 8

样例输出3

5

加入题单

上一题 下一题 算法标签: