poj 3320 尺取法
来源:互联网 发布:郑州php培训哪家好 编辑:程序博客网 时间:2024/04/29 01:13
这道题,用std::ios::sync_with_stdio(false);都超时,非得用scanf();
#include<iostream>#include<cstdio>#include<map>#include<vector>#include<set>using namespace std;int a[1000002];set<int>s;map<int,int>mp;int main(){int n;scanf("%d",&n);int i,j;for(i=0;i<n;i++){scanf("%d",&a[i]);s.insert(a[i]);}int len=s.size();intcot=0; int ans=0x3f3f3f3f;int start=0;j=0;while(1){while(cot<len&&j<n){if(mp[a[j]]==0){cot++;}mp[a[j]]++;j++;}if(cot<len)break;ans=min(ans,j-start);mp[a[start]]--;if(mp[a[start]]==0)cot--;start++;}printf("%d\n",ans);}
0 0
- poj 3320 尺取法
- poj 3320 尺取法
- poj 3320 尺取法
- POJ 3320 (尺取法)
- poj 3320 尺取法
- poj 3320 尺取法
- poj 3320 尺取法
- ACM 尺取法 poj 3320
- poj 3320 (尺取法)
- POJ 3320 (尺取法 map)
- poj 3320 尺取法经典
- poj 3061 3320 尺取法的应用
- POJ 3320 尺取法 + map + set
- 尺取法(POJ 3061,3320,3276)
- poj 3320 尺取法 + map + set
- POJ 2566 尺取法
- poj 2100 尺取法
- POJ 2566 尺取法
- HDOJ-3788 ZOJ问题(递推)
- 每日一题G 2015/6/3 16:38
- java double比较大小
- 畅通工程(1863)
- 黑马程序员_关于类本质的小结
- poj 3320 尺取法
- 学习PHP那点事…
- 第十三周 项目二 形状类族中的纯虚函数
- PLSQL中文插入乱码问题解决方法
- 设计模式(四):适配器模式
- Excel导入导出(二)导入模版定制
- SQL在线优化工具(支持java String 和String Bufer)
- hdoj2151简单的计数DP
- android如何在Eclipse无法运行,如何生成apk文件