【Codeforces Round #426 (Div. 2) B】The Festive Evening
模拟水题;
注意一个字母单个出现的时候,结束和开始一起写;
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
char s[(int) 1e6+100];
int rest[500],now[500];
main(){
scanf("%lld%lld",&n,&k);
scanf("%s",s+1);
for (int i = 1;i <= n;i++)
rest[s[i]]++;
int temp = 0;
for (int i = 1;i <= n;i++){
now[s[i]]++;
if (now[s[i]]==1){
temp++;
if (temp>k){
return puts("YES"),0;
}
}
if (now[s[i]]==rest[s[i]]){
temp--;
}
}
puts("NO");
return 0;
}