zoukankan      html  css  js  c++  java
  • 【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;
    }
  • 相关阅读:
    协议与接口相关
    jmeter 使用(1)
    jmeter 压力测试
    shell脚本的规则
    charles的原理及使用
    Linux环境部署和项目构建
    面向对象
    python 基础练习题
    jmeter 使用(2)
    Ext.apply
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626113.html
Copyright © 2011-2022 走看看