博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ3320:Jessica's Reading Problem(尺取法)
阅读量:7194 次
发布时间:2019-06-29

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

Jessica's Reading Problem
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 11567   Accepted: 3925

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

Source

, Jerry
题意:书本有p页,p[i]指第i页的知识点种类,求涵盖所有知识点种类的最小连续区间。
# include 
# include
# include
# include
using namespace std;int a[1000001], p;void solve(int n){ int ans = p, l=0, r=0, num=0; map
m; while(1) { while(r

转载于:https://www.cnblogs.com/junior19/p/6729971.html

你可能感兴趣的文章
Activemq构建高并发、高可用的大规模消息系统
查看>>
弹弹弹,弹走鱼尾纹的弹出菜单(vue)
查看>>
ppwjs之bootstrap网格系统:插入行
查看>>
Java中spring boot2集成ES案例详解
查看>>
java版b2b2c社交电商spring cloud分布式微服务 (三) 服务消费者(Feign)
查看>>
Django入门
查看>>
MySQL新建用户,授权,撤权,删除用户,修改密码
查看>>
background-position 用法详细介绍
查看>>
SPAN端口镜像
查看>>
【Anychat音视频】视频直播系统
查看>>
shell语法练习之实现简单计算器
查看>>
windows下时间转换和获取当前时间
查看>>
EM3096二维扫描模块在手持终端设备上的应用
查看>>
HADOOP INSTALL
查看>>
openshift
查看>>
Latex 宏包编写,自定义宏包
查看>>
PHPStorm激活
查看>>
Shiro学习笔记<2>SecurityUtils,SecurityManager,Subject
查看>>
修改数据库密码
查看>>
多态存在的条件
查看>>