A12022 | Kitchen Utensils
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The king's birthday dinner was attended by $k$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensils.
All types of utensils in the kingdom are numbered from $1$ to $100$ . It is known that every set of utensils is the same and consist of different types of utensils, although every particular type may appear in the set at most once. For example, a valid set of utensils can be composed of one fork, one spoon and one knife.
After the dinner was over and the guests were dismissed, the king wondered what minimum possible number of utensils could be stolen. Unfortunately, the king has forgotten how many dishes have been served for every guest but he knows the list of all the utensils left after the dinner. Your task is to find the minimum possible number of stolen utensils.
All types of utensils in the kingdom are numbered from $1$ to $100$ . It is known that every set of utensils is the same and consist of different types of utensils, although every particular type may appear in the set at most once. For example, a valid set of utensils can be composed of one fork, one spoon and one knife.
After the dinner was over and the guests were dismissed, the king wondered what minimum possible number of utensils could be stolen. Unfortunately, the king has forgotten how many dishes have been served for every guest but he knows the list of all the utensils left after the dinner. Your task is to find the minimum possible number of stolen utensils.
输入格式
The first line contains two integer numbers $n$ and $k$ ( $1 \le n \le 100, 1 \le k \le 100$ ) — the number of kitchen utensils remaining after the dinner and the number of guests correspondingly.
The next line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 100$ ) — the types of the utensils remaining. Equal values stand for identical utensils while different values stand for different utensils.
The next line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 100$ ) — the types of the utensils remaining. Equal values stand for identical utensils while different values stand for different utensils.
输出格式
Output a single value — the minimum number of utensils that could be stolen by the guests.
输入输出样例
输入 #1
5 2 1 2 2 1 3
输出 #1
1
输入 #2
10 3 1 3 3 1 3 5 5 5 5 100
输出 #2
14
In the first example it is clear that at least one utensil of type $3$ has been stolen, since there are two guests and only one such utensil. But it is also possible that every person received only one dish and there were only six utensils in total, when every person got a set $(1, 2, 3)$ of utensils. Therefore, the answer is $1$ .
One can show that in the second example at least $2$ dishes should have been served for every guest, so the number of utensils should be at least $24$ : every set contains $4$ utensils and every one of the $3$ guests gets two such sets. Therefore, at least $14$ objects have been stolen. Please note that utensils of some types (for example, of types $2$ and $4$ in this example) may be not present in the set served for dishes.
One can show that in the second example at least $2$ dishes should have been served for every guest, so the number of utensils should be at least $24$ : every set contains $4$ utensils and every one of the $3$ guests gets two such sets. Therefore, at least $14$ objects have been stolen. Please note that utensils of some types (for example, of types $2$ and $4$ in this example) may be not present in the set served for dishes.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted