POJ 3320
来源:互联网 发布:php json转数组为null 编辑:程序博客网 时间:2024/06/06 05:11
500ms#include <iostream>#include<cstdio>#include<map> //知识点和出现次数的映射#include<set>#include<algorithm>using namespace std;const int maxn=1000000;int p;int a[maxn];map<int,int> maze;set<int>all;int res;int main(){ while(scanf("%d",&p)==1) { for(int i=0;i<p;i++) { scanf("%d",&a[i]); all.insert(a[i]); } int n=all.size(); //所有不同知识点的个数 int s=0,t=0,num=0; //s为前界,t为后界 res=p; //储存最小的连续页数 //尺取法 for(;;) { while(t<p&&num<n) //未得到全部知识点 { if(maze[a[t]]==0) //得到新的知识点 num++; maze[a[t]]++; t++; } if(num<n) break; res=min(res,t-s); maze[a[s]]--; if(maze[a[s]]==0) num--; s++; } cout<<res<<endl; } 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 尺取法
- SQL Server 数据库的创建、删除、修改
- vuejs开发音乐播放器(二):从歌手页面到歌手详情页面的子路由跳转
- No.14 【大数据算法】BitMap的原理和实现
- 解析json是数组的数据
- 希尔排序
- POJ 3320
- Java重载、重写及重构的区别
- yii框架中文件上传
- No. 15【大数据算法】Bloom Filter 的原理和实现
- TCP/IP协议
- Bitset
- 分享两个线+标注的SLD样式
- uva11175
- The Stack Is An Implementation Detail, Part One