题目链接:http://codeforces.com/problemset/problem/841/A

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

题解:水水

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
const int N=;
char a[];
int main()
{
int n,k;
while(cin>>n>>k){
for(int i=;i<n;i++)
cin>>a[i];
sort(a,a+n);
int m=,t=;
for(int i=;i<n;i++){
if(a[i]==a[i-]){
t++;
if(t>m) m=t;
}
else t=;
}
if(m>k) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return ;
}

Codeforces 841A - Generous Kefa的更多相关文章

  1. Codeforces Round #429 (Div. 2/Div. 1) [ A/_. Generous Kefa ] [ B/_. Godsend ] [ C/A. Leha and Function ] [ D/B. Leha and another game about graph ] [ E/C. On the Bench ] [ _/D. Destiny ]

    PROBLEM A/_ - Generous Kefa 题 OvO http://codeforces.com/contest/841/problem/A cf 841a 解 只要不存在某个字母,它的 ...

  2. Codeforces Round #429 (Div. 2) A. Generous Kefa【hash/判断字符串是否有一种字符个数大于m】

    A. Generous Kefa time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  3. 【codeforces841A】Generous Kefa

    原题 A. Generous Kefatime limit per test:2 secondsmemory limit per test:256 megabytes input:standard i ...

  4. 【Codeforces Round #429 (Div. 2) A】Generous Kefa

    [Link]:http://codeforces.com/contest/841/problem/A [Description] [Solution] 模拟,贪心,每个朋友尽量地多给气球. [Numb ...

  5. Codeforces 580B: Kefa and Company(前缀和)

    http://codeforces.com/problemset/problem/580/B 题意:Kefa有n个朋友,要和这n个朋友中的一些出去,这些朋友有一些钱,并且和Kefa有一定的友谊值,要求 ...

  6. codeforces 580D:Kefa and Dishes

    Description When Kefa came to the restaurant and sat at a table, the waiter immediately brought him ...

  7. codeforces#580 D. Kefa and Dishes(状压dp)

    题意:有n个菜,每个菜有个兴奋值,并且如果吃饭第i个菜立即吃第j个菜,那么兴奋值加ma[i][j],求吃m个菜的最大兴奋值,(n<=18) 分析:定义dp[status][last],statu ...

  8. codeforces Round#429 (Div2)

    2017-08-20 10:00:37 writer:pprp 用头文件#include <bits/stdc++.h>很方便 A. Generous Kefa codeforces 84 ...

  9. Kefa and Park

    #include<bits/stdc++.h> #define max 100005 using namespace std; int cats[max]; vector<int&g ...

随机推荐

  1. mysql 初识数据库 目录

    数据库管理软件的由来 数据库概述 MySQL介绍 Window版本 安装mysql linux 安装mysql yum方式 windows平台mysql密码设置 windows平台mysql密码破解设 ...

  2. zabbix 3.2源码安装

    环境: centos7.2 nginx 1.10.3 mysql 5.5.38 php 5.5.38 一.zabbix介绍 1.Zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企 ...

  3. mysql之event

    mysql之event http://blog.csdn.net/lxgwm2008/article/details/9088521 Mysql事件调度器(Event Scheduler)类似于定时器 ...

  4. 初试GH-OST(转)

    最近老板让做一个gh-ost和pt-osc 的对比测试,本文将对两者做对比. 一.原理和所用说明   PT-OSC GH-OST 原理 1.创建一个和要执行 alter 操作的表一样的新的空表结构(是 ...

  5. ftp工具类

    package com.ytd.zjdlbb.service.zjdlbb; import java.io.File;import java.io.FileInputStream;import jav ...

  6. 【LNMP】提示Nginx PHP “No input file specified”错误的解决办法

    原理: 任何对.php文件的请求,都简单地交给php-cgi去处理,但没有验证该php文件是否存在. PHP文件不存在,没办法返回普通的404错误,它返回 一个404,并带上一句”No input f ...

  7. Spark学习:ShutdownHookManager虚拟机关闭钩子管理器

    Java程序经常也会遇到进程挂掉的情况,一些状态没有正确的保存下来,这时候就需要在JVM关掉的时候执行一些清理现场的代码. JAVA中的ShutdownHook提供了比较好的方案. JDK提供了Jav ...

  8. Pro*C介绍

    内嵌SQL 概要 Pro*C语法 SQL 预处理指令 语句标号 宿主变量 基础 指针 结构 数组 指示器变量 数据类型同等化 动态SQL 事务 错误处理 SQLCA WHENEVER语句 Demo程序 ...

  9. Linux下的python等操作【转载】

    转自:https://blog.csdn.net/healthy_coder/article/details/50546384 https://blog.csdn.net/boyun58/articl ...

  10. 【LeetCode每天一题】Generate Parentheses(创造有效的括弧)

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...