A. Generous Kefa

Codeforces
IDCF841A
Time2000ms
Memory256MB
Difficulty
brute forceimplementation
English · Original
Chinese · Translation
Formal · Original
One day Kefa found _n_ baloons. For convenience, we denote color of _i_\-th baloon as _s__i_ — 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. [samples] ## 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_».
一天,Kefa 找到了 #cf_span[n] 个气球。为方便起见,我们记第 #cf_span[i] 个气球的颜色为 #cf_span[si] —— 拉丁字母的小写字母。同时,Kefa 有 #cf_span[k] 个朋友。如果一个朋友收到两个颜色相同的气球,他会不高兴。Kefa 希望将 *所有* 气球分发给他的朋友们。请帮助 Kefa 判断,他是否能将所有气球分发出去,使得没有任何朋友不高兴——如果可以,请输出 «_YES_»,否则输出 «_NO_»。注意,如果一个朋友没有收到任何气球,他不会不高兴。 第一行包含两个整数 #cf_span[n] 和 #cf_span[k] (#cf_span[1 ≤ n, k ≤ 100]) —— 气球和朋友的数量。 第二行包含字符串 #cf_span[s] —— 气球的颜色。 输出该问题的答案 —— 单行输出 «_YES_» 或 «_NO_»。 你可以任意选择每个字母的大小写。 在第一个样例中,Kefa 可以将第 #cf_span[1] 个和第 #cf_span[3] 个气球给第一个朋友,将第 #cf_span[2] 个和第 #cf_span[4] 个气球给第二个朋友。 在第二个样例中,Kefa 需要将所有颜色为 _a_ 的气球分给他的朋友们,但会剩下一个气球,因此答案是 «_NO_»。 ## Input 第一行包含两个整数 #cf_span[n] 和 #cf_span[k] (#cf_span[1 ≤ n, k ≤ 100]) —— 气球和朋友的数量。第二行包含字符串 #cf_span[s] —— 气球的颜色。 ## Output 输出该问题的答案 —— 单行输出 «_YES_» 或 «_NO_»。你可以任意选择每个字母的大小写。 [samples] ## Note 在第一个样例中,Kefa 可以将第 #cf_span[1] 个和第 #cf_span[3] 个气球给第一个朋友,将第 #cf_span[2] 个和第 #cf_span[4] 个气球给第二个朋友。在第二个样例中,Kefa 需要将所有颜色为 _a_ 的气球分给他的朋友们,但会剩下一个气球,因此答案是 «_NO_»。
**Definitions** Let $ n, k \in \mathbb{Z} $ be the number of balloons and friends, respectively. Let $ s \in \Sigma^n $ be a string of length $ n $ over the alphabet $ \Sigma $ of lowercase Latin letters, where $ s_i $ denotes the color of the $ i $-th balloon. Let $ c: \Sigma \to \mathbb{Z}_{\geq 0} $ be the frequency function, where $ c(\chi) $ is the number of balloons of color $ \chi $. **Constraints** 1. $ 1 \leq n, k \leq 100 $ 2. $ s_i \in \{a, b, \dots, z\} $ for all $ i \in \{1, \dots, n\} $ **Objective** Determine whether it is possible to assign all $ n $ balloons to $ k $ friends such that no friend receives two balloons of the same color. This is possible if and only if: $$ \max_{\chi \in \Sigma} c(\chi) \leq k $$ Output "YES" if the condition holds, otherwise "NO".
Samples
Input #1
4 2
aabb
Output #1
YES
Input #2
6 3
aacaab
Output #2
NO
API Response (JSON)
{
  "problem": {
    "name": "A. Generous Kefa",
    "description": {
      "content": "One day Kefa found _n_ baloons. For convenience, we denote color of _i_\\-th baloon as _s__i_ — lowercase letter of the Latin alphabet. Also Kefa has _k_ friends. Friend will be upset, If he get two ba",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF841A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "One day Kefa found _n_ baloons. For convenience, we denote color of _i_\\-th baloon as _s__i_ — lowercase letter of the Latin alphabet. Also Kefa has _k_ friends. Friend will be upset, If he get two ba...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "一天,Kefa 找到了 #cf_span[n] 个气球。为方便起见,我们记第 #cf_span[i] 个气球的颜色为 #cf_span[si] —— 拉丁字母的小写字母。同时,Kefa 有 #cf_span[k] 个朋友。如果一个朋友收到两个颜色相同的气球,他会不高兴。Kefa 希望将 *所有* 气球分发给他的朋友们。请帮助 Kefa 判断,他是否能将所有气球分发出去,使得没有任何朋友不高兴——如...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, k \\in \\mathbb{Z} $ be the number of balloons and friends, respectively.  \nLet $ s \\in \\Sigma^n $ be a string of length $ n $ over the alphabet $ \\Sigma $ of lowercase Latin ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments