CodeForces - 834B

网友投稿 531 2022-10-21

CodeForces - 834B

CodeForces - 834B

It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom of Sweetland in case it turns out to reach the wrong hands. So it's a necessity to not let any uninvited guests in.

There are 26 entrances in Jelly Castle, enumerated with uppercase English letters from A to Z. Because of security measures, each guest is known to be assigned an entrance he should enter the castle through. The door of each entrance is opened right before the first guest's arrival and closed right after the arrival of the last guest that should enter the castle through this entrance. No two guests can enter the castle simultaneously.

For an entrance to be protected from possible intrusion, a candy guard should be assigned to it. There are k such guards in the castle, so if there are more than k

Slastyona had a suspicion that there could be uninvited guests at the evening. She knows the order in which the invited guests entered the castle, and wants you to help her check whether there was a moment when more than k

Input

Two integers are given in the first string: the number of guests n and the number of guards k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26).

In the second string, n uppercase English letters s1s2... sn are given, where si is the entrance used by the i-th guest.

Output

Output «YES» if at least one door was unguarded during some time, and «NO» otherwise.

You can output each letter in arbitrary case (upper or lower).

Example

Input

5 1AABBB

Output

NO

Input

5 1ABABB

Output

YES

题目大概:

有客人要进城堡,城堡有26个门,每个门都可以进。当有人要从一个门进的时候必须要有守卫看守,当这个门的最后一个人进入后,守卫才可以离开,中间不能离开,问是否要添加守卫。

思路:

把这些门都设为数组,有人要从该门进,就a[]++,并要有守卫。当进去后再把这个人减出来,当人为零是该门就不需要守卫了。看看是否守卫数量是负数。

代码

#include #include #include #include using namespace std;int b;int a[27]={0},p[27]={0};int main(){int n,f=0;cin>>n>>b;string s;cin>>s;for(int i=0;i

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Quinet是一个简单的客户端网络并发框架, 其基于Python的gevent库(即协程)
下一篇:Bad Hair Day (单调队列)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~