#include<iostream>
#include<map>
#include<climits>
#include<algorithm>
#include<set>
using namespace std;
int a[1000010];
int main()
{
int p;
cin>>p;
for(int i=0;i<p;i++)
cin>>a;
set<int> couse;
for(int i=0;i<p;i++)
couse.insert(a);
int cc=couse.size(); //couse count
map<int,int> c;
int s=0,t=0;
int ans=INT_MAX;
while(t<=p)
{
if(c.size()>=cc)
{
ans=min(ans,t-s);
c[a]--;
if(c[a]==0)
c.erase(a);
s++;
}
else
{
c[a[t]]++;
t++;
}
}
cout<<ans<<endl;
}
歡迎光臨 竹園論壇 (http://forum.tfcis.org/) | Powered by Discuz! X3.2 |