Codeforces 841A - Generous Kefa
题目链接: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.
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.
Answer to the task — «YES» or «NO» in a single line.
You can choose the case (lower or upper) for each letter arbitrary.
4 2
aabb
YES
6 3
aacaab
NO
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的更多相关文章
- 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 解 只要不存在某个字母,它的 ... 
- 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 ... 
- 【codeforces841A】Generous Kefa
		原题 A. Generous Kefatime limit per test:2 secondsmemory limit per test:256 megabytes input:standard i ... 
- 【Codeforces Round #429 (Div. 2) A】Generous Kefa
		[Link]:http://codeforces.com/contest/841/problem/A [Description] [Solution] 模拟,贪心,每个朋友尽量地多给气球. [Numb ... 
- Codeforces 580B: Kefa and Company(前缀和)
		http://codeforces.com/problemset/problem/580/B 题意:Kefa有n个朋友,要和这n个朋友中的一些出去,这些朋友有一些钱,并且和Kefa有一定的友谊值,要求 ... 
- codeforces 580D:Kefa and Dishes
		Description When Kefa came to the restaurant and sat at a table, the waiter immediately brought him ... 
- codeforces#580 D. Kefa and Dishes(状压dp)
		题意:有n个菜,每个菜有个兴奋值,并且如果吃饭第i个菜立即吃第j个菜,那么兴奋值加ma[i][j],求吃m个菜的最大兴奋值,(n<=18) 分析:定义dp[status][last],statu ... 
- codeforces Round#429 (Div2)
		2017-08-20 10:00:37 writer:pprp 用头文件#include <bits/stdc++.h>很方便 A. Generous Kefa codeforces 84 ... 
- Kefa and Park
		#include<bits/stdc++.h> #define max 100005 using namespace std; int cats[max]; vector<int&g ... 
随机推荐
- 虚拟货币ICO是什么意思 看完秒懂
			有这样一个市场,与90年代的互联网泡沫及其相似,它被许多金融界大咖怒指为丧失道德底线的圈钱工具,更被投资者而疯狂追捧.是的,没错,它就是近二年火遍全球的虚拟货币ICO.那么,对于很多投资小白来说,虚拟 ... 
- mac-禅道环境
			开机不能访问,换成IP地址就好了 
- node操作 windows的appdata本地缓存文件
			const os = require('os'); const path = require("path"); const fs = require("fs") ... 
- mac date
			格式化UTC为可读格式 mbp:~ gavin$ date -r 1546848158 2019年 1月 7日 星期一 16时02分38秒 CST 获取当前 UTC mbp:~ gavin$ date ... 
- MySQL--8MySQL存储过程小结
			CURD: 就是对数据表进行插入更新删除查找的操作. 预编译:第一次会分析语法是否正确,编译成可识别的命令.然后存在内存中,以后再调用就省去了这两步,效率变高. 第一点:在存储过程内可以写控制语句,可 ... 
- vmware 12
			下载地址 (linux:https://download3.vmware.com/software/wkst/file/VMware-Workstation-Full-12.1.1-3770994.x ... 
- Python_summary
			Q: python中出现IndentationError:unindent does not match any outer indentation levelA:复制代码的时候容易出现缩进错误,虽然 ... 
- bootstrap ui
			附加访问地址:http://www.bootcss.com/p/jquery-ui-bootstrap/ 
- python入门之列表
			1.列表基本格式# list 类 列表li = [1, 2, 3, "sb", ["时间",[9, 10], "huang"], 6, 7, ... 
- 函数max()优化
			函数max的优化 用途:查询最后支付时间-优化max函数 语句: select max(payment_date)from payment 执行计划: 
