博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Jessica's Reading Problem
阅读量:6576 次
发布时间:2019-06-24

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

Description

Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas included in a very thick text book. The author of that text book, like other authors, is extremely fussy about the ideas, thus some ideas are covered more than once. Jessica think if she managed to read each idea at least once, she can pass the exam. She decides to read only one contiguous part of the book which contains all ideas covered by the entire book. And of course, the sub-book should be as thin as possible.

A very hard-working boy had manually indexed for her each page of Jessica's text-book with what idea each page is about and thus made a big progress for his courtship. Here you come in to save your skin: given the index, help Jessica decide which contiguous part she should read. For convenience, each idea has been coded with an ID, which is a non-negative integer.

Input

The first line of input is an integer P (1 ≤ P ≤ 1000000), which is the number of pages of Jessica's text-book. The second line contains P non-negative integers describing what idea each page is about. The first integer is what the first page is about, the second integer is what the second page is about, and so on. You may assume all integers that appear can fit well in the signed 32-bit integer type.

Output

Output one line: the number of pages of the shortest contiguous part of the book which contains all ideals covered in the book.

Sample Input

51 8 8 8 1

Sample Output

2
1 #include"iostream" 2 #include"cstdio" 3 #include"cstring" 4 #include"algorithm" 5 #include"set" 6 #include"map" 7 using namespace std; 8 const int ms=1000001; 9 int a[ms];10 int P;11 void solve()12 {13     set
S;14 for(int i=0;i
mp;19 while(1)20 {21 while(t

 

转载于:https://www.cnblogs.com/767355675hutaishi/p/3950057.html

你可能感兴趣的文章
【leetcode】538. Convert BST to Greater Tree
查看>>
【shell】sed指定追加模式空间的次数
查看>>
HTTP 返回码中 301 与 302 的区别
查看>>
51Nod1089最长回文子串 V2(Manacher算法)
查看>>
每个程序员都该学习的5种开发语言
查看>>
Android Studio发布Release版本之坑--Unknown host 'd29vzk4ow07wi7.cloudfront.net'
查看>>
java服务器获取客户端ip
查看>>
virtualbox直接搭建laravel开发环境可能遇到的坑
查看>>
c++ try throw catch
查看>>
Python编程系列教程第14讲——继承
查看>>
安利一款基于element的大数据树形表格
查看>>
git log
查看>>
Mint UI 使用采坑记
查看>>
数据库下载_Office下载
查看>>
leetcode-771-Jewels and Stones(建立哈希表,降低时间复杂度)
查看>>
字符串分割函数(New)
查看>>
第一阶段:前端开发_使用JS完成注册页面表单校验
查看>>
深入了解JavaScript对象(1)--原始类型和引用类型
查看>>
mybatis中动态SQL之trim详解
查看>>
SDN第5次上机作业
查看>>