A13984 | Advertising Agency
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of $n$ different bloggers. Blogger numbered $i$ has $a_i$ followers.
Since Masha has a limited budget, she can only sign a contract with $k$ different bloggers. Of course, Masha wants her ad to be seen by as many people as possible. Therefore, she must hire bloggers with the maximum total number of followers.
Help her, find the number of ways to select $k$ bloggers so that the total number of their followers is maximum possible. Two ways are considered different if there is at least one blogger in the first way, which is not in the second way. Masha believes that all bloggers have different followers (that is, there is no follower who would follow two different bloggers).
For example, if $n=4$ , $k=3$ , $a=[1, 3, 1, 2]$ , then Masha has two ways to select $3$ bloggers with the maximum total number of followers:
- conclude contracts with bloggers with numbers $1$ , $2$ and $4$ . In this case, the number of followers will be equal to $a_1 + a_2 + a_4 = 6$ .
- conclude contracts with bloggers with numbers $2$ , $3$ and $4$ . In this case, the number of followers will be equal to $a_2 + a_3 + a_4 = 6$ .
Since the answer can be quite large, output it modulo $10^9+7$ .
Since Masha has a limited budget, she can only sign a contract with $k$ different bloggers. Of course, Masha wants her ad to be seen by as many people as possible. Therefore, she must hire bloggers with the maximum total number of followers.
Help her, find the number of ways to select $k$ bloggers so that the total number of their followers is maximum possible. Two ways are considered different if there is at least one blogger in the first way, which is not in the second way. Masha believes that all bloggers have different followers (that is, there is no follower who would follow two different bloggers).
For example, if $n=4$ , $k=3$ , $a=[1, 3, 1, 2]$ , then Masha has two ways to select $3$ bloggers with the maximum total number of followers:
- conclude contracts with bloggers with numbers $1$ , $2$ and $4$ . In this case, the number of followers will be equal to $a_1 + a_2 + a_4 = 6$ .
- conclude contracts with bloggers with numbers $2$ , $3$ and $4$ . In this case, the number of followers will be equal to $a_2 + a_3 + a_4 = 6$ .
Since the answer can be quite large, output it modulo $10^9+7$ .
输入格式
The first line contains one integer $t$ ( $1 \le t \le 1000$ ) — the number of test cases. Then $t$ test cases follow.
The first line of each test case contains two integers $n$ and $k$ ( $1 \le k \le n \le 1000$ ) — the number of bloggers and how many of them you can sign a contract with.
The second line of each test case contains $n$ integers $a_1, a_2, \ldots a_n$ ( $1 \le a_i \le n$ ) — the number of followers of each blogger.
It is guaranteed that the sum of $n$ over all test cases does not exceed $1000$ .
The first line of each test case contains two integers $n$ and $k$ ( $1 \le k \le n \le 1000$ ) — the number of bloggers and how many of them you can sign a contract with.
The second line of each test case contains $n$ integers $a_1, a_2, \ldots a_n$ ( $1 \le a_i \le n$ ) — the number of followers of each blogger.
It is guaranteed that the sum of $n$ over all test cases does not exceed $1000$ .
输出格式
For each test case, on a separate line output one integer — the number of ways to select $k$ bloggers so that the total number of their followers is maximum possible.
输入输出样例
输入 #1
3 4 3 1 3 1 2 4 2 1 1 1 1 2 1 1 2
输出 #1
2 6 1
The test case is explained in the statements.
In the second test case, the following ways are valid:
- conclude contracts with bloggers with numbers $1$ and $2$ . In this case, the number of followers will be equal to $a_1 + a_2 = 2$ ;
- conclude contracts with bloggers with numbers $1$ and $3$ . In this case, the number of followers will be equal to $a_1 + a_3 = 2$ ;
- conclude contracts with bloggers with numbers $1$ and $4$ . In this case, the number of followers will be equal to $a_1 + a_4 = 2$ ;
- conclude contracts with bloggers with numbers $2$ and $3$ . In this case, the number of followers will be equal to $a_2 + a_3 = 2$ ;
- conclude contracts with bloggers with numbers $2$ and $4$ . In this case, the number of followers will be equal to $a_2 + a_4 = 2$ ;
- conclude contracts with bloggers with numbers $3$ and $4$ . In this case, the number of followers will be equal to $a_3 + a_4 = 2$ .
In the third test case, the following ways are valid:
- concludes a contract with a blogger with the number $2$ . In this case, the number of followers will be equal to $a_2 = 2$ .
In the second test case, the following ways are valid:
- conclude contracts with bloggers with numbers $1$ and $2$ . In this case, the number of followers will be equal to $a_1 + a_2 = 2$ ;
- conclude contracts with bloggers with numbers $1$ and $3$ . In this case, the number of followers will be equal to $a_1 + a_3 = 2$ ;
- conclude contracts with bloggers with numbers $1$ and $4$ . In this case, the number of followers will be equal to $a_1 + a_4 = 2$ ;
- conclude contracts with bloggers with numbers $2$ and $3$ . In this case, the number of followers will be equal to $a_2 + a_3 = 2$ ;
- conclude contracts with bloggers with numbers $2$ and $4$ . In this case, the number of followers will be equal to $a_2 + a_4 = 2$ ;
- conclude contracts with bloggers with numbers $3$ and $4$ . In this case, the number of followers will be equal to $a_3 + a_4 = 2$ .
In the third test case, the following ways are valid:
- concludes a contract with a blogger with the number $2$ . In this case, the number of followers will be equal to $a_2 = 2$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted