提交的时候出segment fault ,我看了也不是数组开小的问题,
#include <bits/stdc++.h>
#include
#include
#include
typedef long long ll;
using namespace std;
const int N=1e6+10;
int check[N];//检查相同元素的个数
queue a;
int main()
{
int p;
cin>>p;
int mx=0;
int k;
int i;
int l;
int temp=0;
for(i=0; i<p; i++)
{
cin>>k;
if(check[k]==0)
{
a.push(k);
check[k]++;
l=a.size();
mx=max(l,mx);
}
else if(check[k]!=0)
{
temp=0;
while(1)
{
if(a.front()==k)
{
a.pop();
a.push(k);
check[k]=1;
temp=1;
l=a.size();
mx=max(l,mx);
break;
}else
{
a.pop();
}
if(temp==1) break;
}
}
}
cout<<mx<<endl;
return 0;
}