#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int moder = 1e9 + ;
const int maxn = ; int a[maxn]; int main()
{
int P;
scanf("%d",&P);
for(int i=;i < P;i++)
scanf("%d",&a[i]); set<int>st;
for(int i=;i < P;i++)
st.insert(a[i]); int n = st.size(); int s=,t=,num=;
map<int,int>cnt;
int res = P+;
for(;;)
{
while(t < P && num < n)
{
if(cnt[a[t]] == )
{
num++;
}
cnt[a[t]]++;
t++;
}
if(num < n) break;
res = min(res,t-s);
if(--cnt[a[s++]] == )
{
num--;
}
}
printf("%d\n",res);
return ;
} /*5
1 8 8 8 1 */

map很好用,记住。

最新文章

  1. [BI项目记]-TFS Express备份和恢复
  2. js动态添加行
  3. ubuntu14.04 gedit显示GB2312中文编码
  4. LeetCode(43. Multiply Strings)
  5. testNG中同一个test节点上class的执行顺序
  6. shopnc 二次开发 每日签到积分领取
  7. jquery1.9+获取append后的动态元素
  8. http压力测试
  9. 最新 Arduino 驱动 12接口/户外 LED显示屏/LED点阵屏/LED单元板
  10. C# System.Attribute(验证类)
  11. [置顶] Android框架攻击之Fragment注入
  12. VS怎样创建和使用lib文件
  13. CSS3学习笔记(1)-CSS3选择器
  14. java中super关键字
  15. 魔术常量(Magic constants)
  16. centos 6.8 下安装redmine(缺陷跟踪系统)
  17. python3 第三十一章 - 模块
  18. SpringCloud服务注册与发现
  19. centos6.5上安装redis3.2.1遇见的坑
  20. CXF Spring开发WebService,基于SOAP和REST方式

热门文章

  1. c# BitArray 复制数组 copyto
  2. Celery和Rabbitmq自学
  3. vue知识总汇
  4. android(十五) FTP的两种工作模式
  5. SNMP 原理及配置简述 net-snmp-utils net-snmp 第2版基于SNMP 群体名(community name) 第3版引入了安全性更高的访问控制方法 SNMP协议操作只有4种 Apache的php_snmp 模块
  6. file /etc/httpd/conf.d/php.conf from install of php-5.6.37-1.el7.remi.x86_64 conflicts with file from package mod_php71w-7.1.18-1.w7.x86_64
  7. 528. Random Pick with Weight
  8. Java 泛型通配符上限和通配符下限
  9. url的正则表达式
  10. 20145311实验四 &quot;Android开发基础&quot;