【Codeforces Round #429 (Div. 2) A】Generous Kefa
【Link】:http://codeforces.com/contest/841/problem/A
【Description】
【Solution】
模拟,贪心,每个朋友尽量地多给气球。
【NumberOf WA】
【Reviw】
【Code】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x+1)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
char s[N];
int n,k,num[N];
int main(){
//Open();
//Close();
ri(n),ri(k);
rs(s);
rep1(i,1,n){
num[s[i]-'a'+1]++;
}
rep1(i,1,k){
int cnt = 0;
rep1(i,1,26)
if (num[i]){
cnt++;
num[i]--;
}
n-=cnt;
}
if (n==0){
puts("YES");
}else{
puts("NO");
}
return 0;
}
【Codeforces Round #429 (Div. 2) A】Generous Kefa的更多相关文章
- 【Codeforces Round #429 (Div. 2) C】Leha and Function
[Link]:http://codeforces.com/contest/841/problem/C [Description] [Solution] 看到最大的和最小的对应,第二大的和第二小的对应. ...
- 【Codeforces Round #429 (Div. 2) B】 Godsend
[Link]:http://codeforces.com/contest/841/problem/B [Description] 两个人轮流对一个数组玩游戏,第一个人可以把连续的一段为奇数的拿走,第二 ...
- 【Codeforces Round #429 (Div. 1) B】Leha and another game about graph
[链接]点击打开链接 [题意] 给出一个连通图,并给每个点赋一个d值0或1或-1,要求选出一个边的集合,使得所有的点i要么d[i] == -1,要么 dgree[i] % 2 == d[i],dgr ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
随机推荐
- (WPF)XAML 过程式代码
当代码编译.x:Code 元素的内容将被放到.g.cs文件. <Window x:Class="WpfApplication7.MainWindow" xmlns=" ...
- 关于nios 中printf 的问题
在nios中,有printf的程序,在线调试没有什么问题,但是下到flash里面,程序跑了一段时间就死掉了!JTAG_UART是阻塞式输出,他只是将数据输出到buffer中,等待你上位机读取,当你的b ...
- centos7 ssh免口令认证登录
摘要:centos7, xshell, 公钥, ssh ssh登录方式有口令认证登录和密钥认证登录 接下来本次介绍是ssh密钥登录方式 (1)产生公钥 (2)将公钥放置到centos7的(/root ...
- Windows安全攻略:教你完全修复系统漏洞
Windows安全攻略:教你完全修复系统漏洞 首发:http://safe.it168.com/a2012/0709/1369/000001369740.shtml 目前互联网上的病毒集团越来越猖狂, ...
- Android控件-TabHost(二)
这边再补充一种更为灵活的方法,可以把TabWidget隐藏,用(RadioGroup+RadioButton)来代替,并利用监听器的方式来实现监听点击点击跳转Activity. 在讲解之前,先补充几点 ...
- c#(asp.net) 如何计算两个日期之间相隔天数
1.DateTime t1 = Convert.ToDateTime("2006-1-6"); DateTime t2 = Convert.ToDateTime("200 ...
- IDEA下使用maven的mybatis错误—XXXDao is not known to the MapperRegistry
# IDEA下使用maven的mybatis常见错误(二) 错误类型二:mybatis.xml注册映射文件错误 错误提示:Type interface com.aynu.dao.CountryDao ...
- tr---对来自标准输入的字符进行替换、压缩和删除。
tr命令可以对来自标准输入的字符进行替换.压缩和删除.它可以将一组字符变成另一组字符,经常用来编写优美的单行命令,作用很强大. 语法 tr(选项)(参数) 选项 -c或——complerment:取代 ...
- CCF模拟题 最优配餐
最优配餐 时间限制: 1.0s 内存限制: 256.0MB 问题描述 栋栋最近开了一家餐饮连锁店,提供外卖服务.随着连锁店越来越多,怎么合理的给客户送餐成为了一个急需解决的问题. 栋栋的连锁店所在 ...
- EditPlus 使用技巧以及快捷键
一边阅读,一边动手吧! 为了达到更好的效果,请你先下载我打包的这个 EditPlus压缩包文件(压缩包文件为绿色的EditPlus2.31英文版,含自动完成文件,高亮语法文件和剪切板代码片断文件,这些 ...