300723: CF137B. Permutation

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

Description

Permutation

题意翻译

**题目描述** "作业时间到啦"-- Polycarpus突然想道。当然,他要先做他最喜欢的科目IT(计算机~)Polycarpus奇迹般地在20分钟内做完了除了最后一题以外的所有题目--不过他在最后一题上卡住了。所以Polycarpus想让你帮帮他: 此题定义中,排列就是,在保证1-n个整数都被包含的情况下n个整数的顺序。现在你有一个随机的序列a1,a2,...an(一共n个整数),每个数>=1且<=5000。请帮Polycarpus求出他获得一个排列之前最少需要改变多少数(他不能删除或加入数)。所谓的一次改变就是指把序列中的一个数改掉,比如说换成另一个整数。 **输入格式** 第一行为整数n(1<=n<=5000),也就是序列中数的个数。第二行为所有整数ai的序列(1<=ai<=5000,1<=i<=n) **输出格式** 只输出一个数:最少步数 ~~(样例省略不翻译)~~ **说明/提示** 第一个样例就是一个“排列”,所以不用进行改变; 第二个样例中只需要一次改变(关于数字1的改变),所以答案是2; 第三个样例中我们可以把第二个数变成4,第三个数变成2.

题目描述

"Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him. The sequence of $ n $ integers is called a permutation if it contains all integers from $ 1 $ to $ n $ exactly once. You are given an arbitrary sequence $ a_{1},a_{2},...,a_{n} $ containing $ n $ integers. Each integer is not less than $ 1 $ and not greater than $ 5000 $ . Determine what minimum number of elements Polycarpus needs to change to get a permutation (he should not delete or add numbers). In a single change he can modify any single sequence element (i. e. replace it with another integer).

输入输出格式

输入格式


The first line of the input data contains an integer $ n $ ( $ 1<=n<=5000 $ ) which represents how many numbers are in the sequence. The second line contains a sequence of integers $ a_{i} $ ( $ 1<=a_{i}<=5000,1<=i<=n $ ).

输出格式


Print the only number — the minimum number of changes needed to get the permutation.

输入输出样例

输入样例 #1

3
3 1 2

输出样例 #1

0

输入样例 #2

2
2 2

输出样例 #2

1

输入样例 #3

5
5 3 3 3 1

输出样例 #3

2

说明

The first sample contains the permutation, which is why no replacements are required. In the second sample it is enough to replace the first element with the number 1 and that will make the sequence the needed permutation. In the third sample we can replace the second element with number 4 and the fourth element with number 2.

Input

题意翻译

**题目描述** "作业时间到啦"-- Polycarpus突然想道。当然,他要先做他最喜欢的科目IT(计算机~)Polycarpus奇迹般地在20分钟内做完了除了最后一题以外的所有题目--不过他在最后一题上卡住了。所以Polycarpus想让你帮帮他: 此题定义中,排列就是,在保证1-n个整数都被包含的情况下n个整数的顺序。现在你有一个随机的序列a1,a2,...an(一共n个整数),每个数>=1且<=5000。请帮Polycarpus求出他获得一个排列之前最少需要改变多少数(他不能删除或加入数)。所谓的一次改变就是指把序列中的一个数改掉,比如说换成另一个整数。 **输入格式** 第一行为整数n(1<=n<=5000),也就是序列中数的个数。第二行为所有整数ai的序列(1<=ai<=5000,1<=i<=n) **输出格式** 只输出一个数:最少步数 ~~(样例省略不翻译)~~ **说明/提示** 第一个样例就是一个“排列”,所以不用进行改变; 第二个样例中只需要一次改变(关于数字1的改变),所以答案是2; 第三个样例中我们可以把第二个数变成4,第三个数变成2.

加入题单

算法标签: