CF834B.The Festive Evening
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述

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 opened doors, one of them is going to be left unguarded! Notice that a guard can't leave his post until the door he is assigned to is closed.
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 doors were opened.

七月即将结束——此时果冻城堡正举行一场盛大的晚会!来自王国各地的宾客齐聚于此,共同探讨糖果世界的新潮流。然而,晚会上讨论的某些内容本不应向公众披露:一旦这些信息落入错误之手,便可能在甜点王国(Sweetland)引发纷争。因此,必须严防任何未受邀请的宾客混入。
果冻城堡共有 26 个入口,以大写英文字母 A 至 Z 编号。出于安全考虑,每位宾客均被指定一个应通过的入口进入城堡。每个入口的门会在第一位应从此门进入的宾客抵达前瞬间开启,并在最后一位应从此门进入的宾客抵达后瞬间关闭。任意两位宾客不得同时进入城堡。
为防止潜在的非法闯入,每个入口都需配备一名糖果守卫。城堡中共有 k 名此类守卫;因此,若同一时刻开启的门数超过 k,则至少有一扇门将无人看守!请注意,守卫在其所负责的门关闭之前不得擅离岗位。
斯拉丝托娜怀疑当晚可能混入了未受邀请的宾客。她已知受邀宾客进入城堡的顺序,现请你协助她判断:是否存在某一时刻,开启的门数超过 k?
输入格式
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 _s_1_s_2... s__n are given, where s__i is the entrance used by the i-th guest.
第一行给出两个整数:客人数量 n 和守卫数量 k(1 ≤ n ≤ 106,1 ≤ k ≤ 26)。
第二行给出 n 个大写英文字母 s1s2…sn,其中 si 表示第 i 位客人使用的入口。
输出格式
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).
如果在某个时刻至少有一扇门未被守卫,则输出 «YES»;否则输出 «NO»。
您可以以任意大小写(大写或小写)输出每个字母。
输入输出样例
输入#1
5 1 AABBB
输出#1
NO
输入#2
5 1 ABABB
输出#2
YES
说明/提示
In the first sample case, the door A is opened right before the first guest's arrival and closed when the second guest enters the castle. The door B is opened right before the arrival of the third guest, and closed after the fifth one arrives. One guard can handle both doors, as the first one is closed before the second one is opened.
In the second sample case, the door B is opened before the second guest's arrival, but the only guard can't leave the door A unattended, as there is still one more guest that should enter the castle through this door.
在第一个样例中,门 A 在第一位客人到达前立即开启,并在第二位客人进入城堡时关闭;门 B 在第三位客人到达前立即开启,并在第五位客人到达后关闭。一名守卫即可同时照看这两扇门,因为第一扇门关闭的时间早于第二扇门开启的时间。
在第二个样例中,门 B 在第二位客人到达前开启,但唯一的一名守卫无法离开门 A,因为仍有一位客人需通过该门进入城堡。
输入解题思路,AI测评打分。不知道怎么写?