poj 3320
来源:互联网 发布:友贷资本网络贷款 编辑:程序博客网 时间:2024/05/29 09:29
#include <cstdio>#include <iostream>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>#include <map>#include <set>#include <string>#include <cctype>#include <queue>using namespace std;typedef long long LL;const int inf = 0x3f3f3f3f;const int N = 1000005;set <int> p;map <int ,int>q;int a[N];int main(){ int n, i, s; while(scanf("%d", &n)!=EOF) { p.clear(); q.clear(); for(i = 0 ; i<n; i++) { scanf("%d", &a[i]); p.insert(a[i]); } s = p.size(); int ans = n; int l = 0 , r = 0, sum = 0; while(l < n && r < n) { if(q[a[r]]==0) sum++; q[a[r]]++; while(q[a[l]]>=2) { q[a[l]]--; l++; } if(sum == s) { ans = min(ans , r - l + 1); if(q[a[l]]==1) sum--; q[a[l]]--; l++; } r++; } printf("%d\n", ans); } return 0;}
0 0
- POJ 3320
- poj 3320
- poj 3320
- poj 3320
- 【POJ】3320
- POJ 3320
- 尺取法专题 POJ 3061 POJ 3320 POJ 2566
- POJ 3320 hash
- Poj 3320(two pointers)
- poj 3320 尺取法
- poj 3320 尺取法
- poj 3320 尺取法
- 【尺取】POJ 3320
- POJ 3320 (尺取法)
- poj 3320 尺取
- poj 3320 尺取法
- poj 3320 尺取法
- poj 3320 尺取法
- onchange事件,在chrome浏览器4.30版本失效问题
- Java泛型入门
- [转]VC中char,TCHAR,WCHAR总结
- Bootstrap,随想
- virtualbox ubuntu14.04共享文件夹
- poj 3320
- HDU 5416 dfs
- 基于Qt5.5.0的sql,C++备忘录软件的编写
- 86. Partition List
- Android Service完全解析
- jmeter随笔(13)--jmeter3.0 post body乱码问题
- java基础之注解
- 让Linux流畅你的工作流
- 在vs2013里访问数据库