A. Petya and Catacombs
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.

Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number ti:

  • If Petya has visited this room before, he writes down the minute he was in this room last time;
  • Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i.

Initially, Petya was in one of the rooms at minute 0, he didn't write down number t0.

At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — then number of notes in Petya's logbook.

The second line contains n non-negative integers t1, t2, ..., tn (0 ≤ ti < i) — notes in the logbook.

Output

In the only line print a single integer — the minimum possible number of rooms in Paris catacombs.

Examples
input
2
0 0
output
2
input
5
0 1 0 1 3
output
3
Note

In the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.

In the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.

题意:

地下墓穴有很多房间和房间之间的双向通道,探险家在里面探索房间。如果到了之前来过的房间,探险家会在记录一个数字t,t是他上次到这个房间记录的时间,如果这个房间他没来过他就会标记一个当前时间i小的t。通过这些他记录下来的时间t,让你求出最少房间的可能。

思路:

乍一看很复杂,但是题目线索给的很清晰了,一个房间记录的t有两种可能:1.上次来过t是上一次到达这个房间的时间。2.没来过这个房间,t是小于当前时间的一个数字,想让房间最少,当然是尽量选择第一种可能啊。

如果每次都是访问之前到达过的房间的话,是不会有相同的值出现的,一开始会在1个房间,此时时间为0s,如第一个样例: 0 0 ,第一个0代表0秒在的房间,设为房间1 ,第二个0,就不能代表0s在的房间了,因为0s是在1房间,但1房间上一次访问是1s时,1房间记录的应该是1。矛盾了,所以只能是第二种可能,未到过的房间,0是小于当前时间i的随机数。

实现代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
int n,ans,i,a[],b[];
scanf("%d",&n);
ans = ;
memset(b,,sizeof(b));
for(i=;i<=n;i++)
scanf("%d",&a[i]);
for(i=;i<=n;i++){
if(!b[a[i]])
b[a[i]]=;
//cout<<a[i]<<endl;
else ans++;
}
cout<<ans<<endl;
}

最新文章

  1. Storm基础
  2. AWS国际版的Route 53和CloudFront
  3. CSS3动画属性之Animation
  4. Oracle 10g ORA-01034: ORACLE not available 错误
  5. js时间对象格式化 format(转载)
  6. 烂泥:虚拟化KVM安装与配置
  7. aspcms标签使用经验
  8. oracle - 创建数据库
  9. JAVA并发七(多线程环境中安全使用集合API)
  10. 转 Oracle 12C 之 CDB/PDB用户的创建与对象管理
  11. Asp.Net MVC Https设置
  12. blackbox_exporter介绍
  13. c#UDP协议
  14. ifconfig相关参数及用法说明
  15. QA CodeDiff做什么?什么时间做?
  16. 前端性能优化 —— 减少HTTP请求
  17. 20170906xlVBA_RecursionGetFiles
  18. [转]HTTPS网络流量解密方法探索系列(一)
  19. go 格式化时间戳
  20. bootstrap-datepicker 与bootstrapValidator同时使用时,选择日期后,无法正常触发校验

热门文章

  1. jqgrid 单击行启用行编辑,切换行保存原编辑行
  2. 第三次作业:结对编程--实现表格在APP的导入和显示
  3. 2017-2018-2 『网络对抗技术』Exp3:免杀原理与实践
  4. 20155232《网络对抗》Exp7 网络欺诈防范
  5. REST-framework快速构建API--频率
  6. Js_Eval方法
  7. 软件测试_Loadrunner_APP测试_性能测试_脚本录制_基本操作流程
  8. Python_汇总生成统计报表
  9. (转)OWASP ZAP下载、安装、使用(详解)教程
  10. webWorker