码迷,mamicode.com
首页 > 其他好文 > 详细

Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)B(SET)

时间:2019-08-27 00:51:02      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:while   ace   def   erase   pen   amp   ant   using   bit   

#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[2007];
set<int>s;
int main(){
int n;
cin>>n;
int iend=n+1;
for(int i=1;i<=n;++i)
cin>>a[i];
while(iend>1&&!s.count(a[iend-1]))
s.insert(a[--iend]);
int ans=9999;
for(int i=1;iend<=n+1;++iend){
while(i<iend&&!s.count(a[i]))
s.insert(a[i++]);
ans=min(ans,iend-i);
s.erase(a[iend]);
}
cout<<ans;
return 0;
}

Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)B(SET)

标签:while   ace   def   erase   pen   amp   ant   using   bit   

原文地址:https://www.cnblogs.com/ldudxy/p/11415668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!