A14512 | Bridge Club
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are currently $n$ hot topics numbered from $0$ to $n-1$ at your local bridge club and $2^n$ players numbered from $0$ to $2^n-1$ . Each player holds a different set of views on those $n$ topics, more specifically, the $i$ -th player holds a positive view on the $j$ -th topic if $i\ \&\ 2^j > 0$ , and a negative view otherwise. Here $\&$ denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).
You are going to organize a bridge tournament capable of accommodating at most $k$ pairs of players (bridge is played in teams of two people). You can select teams arbitrarily while each player is in at most one team, but there is one catch: two players cannot be in the same pair if they disagree on $2$ or more of those $n$ topics, as they would argue too much during the play.
You know that the $i$ -th player will pay you $a_i$ dollars if they play in this tournament. Compute the maximum amount of money that you can earn if you pair the players in your club optimally.
You are going to organize a bridge tournament capable of accommodating at most $k$ pairs of players (bridge is played in teams of two people). You can select teams arbitrarily while each player is in at most one team, but there is one catch: two players cannot be in the same pair if they disagree on $2$ or more of those $n$ topics, as they would argue too much during the play.
You know that the $i$ -th player will pay you $a_i$ dollars if they play in this tournament. Compute the maximum amount of money that you can earn if you pair the players in your club optimally.
输入格式
The first line contains two integers $n$ , $k$ ( $1 \le n \le 20$ , $1 \le k \le 200$ ) — the number of hot topics and the number of pairs of players that your tournament can accommodate.
The second line contains $2^n$ integers $a_0, a_1, \dots, a_{2^n-1}$ ( $0 \le a_i \le 10^6$ ) — the amounts of money that the players will pay to play in the tournament.
The second line contains $2^n$ integers $a_0, a_1, \dots, a_{2^n-1}$ ( $0 \le a_i \le 10^6$ ) — the amounts of money that the players will pay to play in the tournament.
输出格式
Print one integer: the maximum amount of money that you can earn if you pair the players in your club optimally under the above conditions.
输入输出样例
输入 #1
3 1 8 3 5 7 1 10 3 2
输出 #1
13
输入 #2
2 3 7 4 5 7
输出 #2
23
输入 #3
3 2 1 9 1 5 7 8 1 1
输出 #3
29
In the first example, the best we can do is to pair together the $0$ -th player and the $2$ -nd player resulting in earnings of $8 + 5 = 13$ dollars. Although pairing the $0$ -th player with the $5$ -th player would give us $8 + 10 = 18$ dollars, we cannot do this because those two players disagree on $2$ of the $3$ hot topics.
In the second example, we can pair the $0$ -th player with the $1$ -st player and pair the $2$ -nd player with the $3$ -rd player resulting in earnings of $7 + 4 + 5 + 7 = 23$ dollars.
In the second example, we can pair the $0$ -th player with the $1$ -st player and pair the $2$ -nd player with the $3$ -rd player resulting in earnings of $7 + 4 + 5 + 7 = 23$ dollars.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted