mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
2b2ae8c977
2300-2399
44 lines
914 B
C++
44 lines
914 B
C++
#include<iostream>
|
|
#include<string.h>
|
|
using namespace std;
|
|
long N,Ans;
|
|
long Hash[300];
|
|
char St[1111111];
|
|
void Solve(void);
|
|
int main()
|
|
{
|
|
while(cin>>N)
|
|
{
|
|
if(!N)
|
|
break ;
|
|
getchar() ;
|
|
Solve() ;
|
|
}
|
|
return 0 ;
|
|
}
|
|
void Solve(void)
|
|
{
|
|
long i=0,j=0,Now,end;
|
|
gets(St);
|
|
memset(Hash,0,sizeof(Hash));
|
|
end=strlen(St);
|
|
for(Ans=0,Now=0;i<end;i++)
|
|
{
|
|
Hash[St[i]]++;
|
|
if(Hash[St[i]]==1)
|
|
{
|
|
Now++;
|
|
while(Now>N)
|
|
{
|
|
Hash[St[j]]--;
|
|
if(Hash[St[j]]==0)
|
|
Now--;
|
|
j++;
|
|
}
|
|
}
|
|
if(i-j+1>Ans)
|
|
Ans=i-j+1;
|
|
}
|
|
cout<<Ans<<endl;
|
|
}
|