博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #445 C. Petya and Catacombs【思维/题意】
阅读量:4321 次
发布时间:2019-06-06

本文共 2276 字,大约阅读时间需要 7 分钟。

C. 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.

【题意】:相同房间写下上一次到达的时间点,不同房间是随机一下,因为题目要最小答案 。

【分析】:每个时间点只会出现一次,出现多次说明是随机的,也就是说出现多次的那些说明是不同房间,那么只要标记出现过的 然后统计再次出现的次数。0这个点也算。

【代码】:

#include 
using namespace std;const int maxn = 1e5*2;int a[maxn];int main(){ int n; cin>>n; for(int i=0;i
>a[i]; } sort(a,a+n); int cnt = 1; for(int i=1;i
View Code

 

转载于:https://www.cnblogs.com/Roni-i/p/7831237.html

你可能感兴趣的文章
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>
从远程库克隆库
查看>>
codeforces Unusual Product
查看>>
hdu4348 - To the moon 可持久化线段树 区间修改 离线处理
查看>>
正则表达式的搜索和替换
查看>>
个人项目:WC
查看>>
地鼠的困境SSL1333 最大匹配
查看>>
flume+elasticsearch+kibana遇到的坑
查看>>
【MM系列】在SAP里查看数据的方法
查看>>
C#——winform
查看>>
CSS3 transform制作的漂亮的滚动式导航
查看>>
《小强升职记——时间管理故事书》读书笔记
查看>>
Alpha 冲刺(3/10)
查看>>
Kaldi中的Chain模型
查看>>
spring中的ResourceBundleMessageSource使用和测试示例
查看>>
css规范 - bem
查看>>
电梯调度程序的UI设计
查看>>
转自 zera php中extends和implements的区别
查看>>
Array.of使用实例
查看>>
【Luogu】P2498拯救小云公主(spfa)
查看>>