Codeforces 841 Generous Kefa(模拟)

来源:互联网 发布:淘宝网店运营策划书 编辑:程序博客网 时间:2024/05/29 17:51

题目地址
题意:给你n个字符,每种字母的个数不超过m。
思路:直接模拟

#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#define N 3010#define LL __int64#define inf 0x3f3f3f3f#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1#define getMid (l+r)>>1#define movel ans<<1#define mover ans<<1|1using namespace std;const LL mod = 1e9 + 7;map<char, int> mapp;int main() {    cin.sync_with_stdio(false);    int n, m;    string str;    while (cin >> n >> m) {        cin >> str;        for (int i = 0; i < str.length(); i++) {            mapp[str[i]]++;        }        for (map<char, int>::iterator it = mapp.begin(); it != mapp.end(); it++) {            if (it->second > m) {                cout << "NO" << endl;                return 0;            }        }        cout << "YES" << endl;    }    return 0;}
原创粉丝点击