原题

A. Generous Kefa
time limit per test:
2 seconds
memory limit per test:
256 megabytes

input:standard input

output:standard output

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

input1

4 2
aabb

output1

YES

input2

6 3
aacaab

output2

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».

题目大意

给一串包含小写字母的字符串,每个字符代表不同颜色的气球,再给出一个人数,问能否把气球发完并保证不存在一个人拿2个相同颜色的气球。

解法

水题:只要保证数量最多的那种颜色的气球不超过人数即可

代码


#include<iostream>
#include<cstdio>
#include<string>
#define MAXX
using namespace std;
int g_n,g_k,g_cnt;
int a[30];
int main(){
string ch;
scanf("%d%d",&g_n,&g_k);
cin>>ch;
int len=ch.size();
for(int i=0;i<len;i++)
a[ch[i]-'a'+1]++;
for(int i=1;i<=26;i++)
if(a[i]>g_k){
cout<<"NO";
return 0;
}
cout<<"YES";
return 0;
}

最新文章

  1. Mac合并分区
  2. 百度地图API功能集锦
  3. Elasticsearch学习笔记(一)
  4. [转]C#读写TEXT文件
  5. 夺命雷公狗mongodb之----mongodb---2---常用命令和技巧
  6. Struts2笔记——ONGL表达式语言
  7. 利用Qt将网页保存为PDF
  8. PHP内置函数getimagesize()的漏洞
  9. Swift是一个提供RESTful HTTP接口的对象存储系统
  10. hdu1395-2^x mod n = 1
  11. c++,模板函数的定义和使用【初探】
  12. UVA - 11637 Garbage Remembering Exam (组合+可能性)
  13. 金9银10,分享几个重要的Android面试题
  14. 3.1 unittest简介
  15. Spark机器学习(7):KMenas算法
  16. Linux之sed、awk
  17. git回退代码到某次commit
  18. pycharm 配置使用
  19. LeetCode-----算法448.找到所有数组中消失的数字
  20. lua 根据函数名字符串来执行函数

热门文章

  1. Jmeter软件安装之Mac
  2. MFC Object 与 Windows Object
  3. 记一次 .NET 某旅行社Web站 CPU爆高分析
  4. C++ primer plus读书笔记——第8章 函数探幽
  5. CRM系统实施中如何避免“踩雷”
  6. Davinci 可视化系统部署安装及简单使用
  7. [OS] 汇编语言
  8. linux系统开机自动挂载光驱 和 fstab文件详解
  9. NFS PersistentVolume(11)
  10. centos7下iperf的安装