Codeforces841A
A. Generous Kefa
One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all baloons to his friends. Help Kefa to find out, can he give out all his baloons, such that no one of his friens will be upset — print «YES», if he can, and «NO», otherwise. Note, that Kefa's friend will not upset, if he doesn't get baloons at all.
Input
The first line contains two integers n and k (1 ≤ n, k ≤ 100) — the number of baloons and friends.
Next line contains string s — colors of baloons.
Output
Answer to the task — «YES» or «NO» in a single line.
You can choose the case (lower or upper) for each letter arbitrary.
Examples
input
4 2
aabb
output
YES
input
6 3
aacaab
output
NO
Note
In the first sample Kefa can give 1-st and 3-rd baloon to the first friend, and 2-nd and 4-th to the second.
In the second sample Kefa needs to give to all his friends baloons of color a, but one baloon will stay, thats why answer is «NO».
//2017-08-22
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int main()
{
int n, k, book[];
string str;
while(cin>>n>>k){
cin>>str;
memset(book, , sizeof(book));
for(int i = ; i < n; i++)
book[str[i]-'a']++;
int maxinum = ;
for(int i = ; i < ; i++){
maxinum = max(maxinum, book[i]);
}
if(maxinum <= k)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
} return ;
}
Codeforces841A的更多相关文章
- 【codeforces841A】Generous Kefa
原题 A. Generous Kefatime limit per test:2 secondsmemory limit per test:256 megabytes input:standard i ...
随机推荐
- Git-工作区和暂存区的概念
工作区(Working Directory):就是在电脑里能看到的目录,如testcase文件夹就是一个工作区. 版本库(Repository):工作区有一个隐藏目录.git,是Git的版本库. ...
- MySQL 排名统计(常用功能函数)
select actor_id,@curr_cnt:=cnt as cnt , ,@rank) as rank, @prev_cnt:=@curr_cnt as dummy from( select ...
- D13——C语言基础学PYTHON
C语言基础学习PYTHON——基础学习D13 20180918内容纲要: 堡垒机运维开发 1.堡垒机的介绍 2.堡垒机的架构 3.小结 4.堡垒机的功能实现需求 1 堡垒机的介绍 百度百科 随着信息安 ...
- 在没有任何投票节点情况下将从节点转换为Primary节点脚本
cfg={ "_id": "rs01", "version": 2, "protocolVersion": Number ...
- 遗忘Windows Server 2008R2密码的处理方法
遗忘Windows Server 2008R2的处理方法 有的时候,我们会由于各种原因忘掉了服务器密码,比如服务器太多,太杂什么的,或直接是被人黑掉了,这个时候我们想要登录,发现我们已经没有办法了,其 ...
- 基于GTK+3 开发远程控制管理软件(C语言实现)系列二 Centos7下开发环境搭建
一.安装gcc gcc-c++ make等编译工具 yum install gcc gcc-c++ kernel-devel 这一步,其实可以不用做,你在安装Centos7的时候,如果选择开发模式安装 ...
- (转) JVM Crash with SIGSEGV - problematic frame - libzip.so
原文:https://stackoverflow.com/questions/38057362/jvm-crash-with-sigsegv-problematic-frame-libzip-so h ...
- Spring Cloud Hystrix
接上篇: Spring Cloud Eureka 使用命令开启两个服务提供者 java -jar .\hello--SNAPSHOT.jar --server.port= java -jar .\he ...
- Disruptor入门
一.什么是 Disruptor Disruptor是一个高性能的异步处理框架,或者可以认为是最快的消息框架(轻量的JMS),也可以认为是一个观察者模式实现,或者事件-监听模式的实现,直接称disrup ...
- postgresql逻辑结构--索引(六)
一.索引简介 二.索引分类 三.创建索引 四.修改索引 五.删除索引