A10032 | Party
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Note the unusual memory limit for the problem.
People working in MDCS (Microsoft Development Center Serbia) like partying. They usually go to night clubs on Friday and Saturday.
There are $N$ people working in MDCS and there are $N$ clubs in the city. Unfortunately, if there is more than one Microsoft employee in night club, level of coolness goes infinitely high and party is over, so club owners will never let more than one Microsoft employee enter their club in the same week (just to be sure).
You are organizing night life for Microsoft employees and you have statistics about how much every employee likes Friday and Saturday parties for all clubs.
You need to match people with clubs maximizing overall sum of their happiness (they are happy as much as they like the club), while half of people should go clubbing on Friday and the other half on Saturday.
People working in MDCS (Microsoft Development Center Serbia) like partying. They usually go to night clubs on Friday and Saturday.
There are $N$ people working in MDCS and there are $N$ clubs in the city. Unfortunately, if there is more than one Microsoft employee in night club, level of coolness goes infinitely high and party is over, so club owners will never let more than one Microsoft employee enter their club in the same week (just to be sure).
You are organizing night life for Microsoft employees and you have statistics about how much every employee likes Friday and Saturday parties for all clubs.
You need to match people with clubs maximizing overall sum of their happiness (they are happy as much as they like the club), while half of people should go clubbing on Friday and the other half on Saturday.
输入格式
The first line contains integer $N$ — number of employees in MDCS.
Then an $N×N$ matrix follows, where element in $i$ -th row and $j$ -th column is an integer number that represents how much $i$ -th person likes $j$ -th club’s Friday party.
Then another $N×N$ matrix follows, where element in $i$ -th row and $j$ -th column is an integer number that represents how much $i$ -th person likes $j$ -th club’s Saturday party.
- $2<=N<=20$
- $N$ is even
- $0<=$ level of likeness $<=10^{6}$
- All values are integers
Then an $N×N$ matrix follows, where element in $i$ -th row and $j$ -th column is an integer number that represents how much $i$ -th person likes $j$ -th club’s Friday party.
Then another $N×N$ matrix follows, where element in $i$ -th row and $j$ -th column is an integer number that represents how much $i$ -th person likes $j$ -th club’s Saturday party.
- $2<=N<=20$
- $N$ is even
- $0<=$ level of likeness $<=10^{6}$
- All values are integers
输出格式
Output should contain a single integer — maximum sum of happiness possible.
输入输出样例
输入 #1
4 1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3 5 8 7 1 6 9 81 3 55 78 1 6 1 1 1 1
输出 #1
167
Here is how we matched people with clubs:
Friday: 1st person with 4th club (4 happiness) and 4th person with 1st club (4 happiness).
Saturday: 2nd person with 3rd club (81 happiness) and 3rd person with 2nd club (78 happiness).
4+4+81+78 = 167
Friday: 1st person with 4th club (4 happiness) and 4th person with 1st club (4 happiness).
Saturday: 2nd person with 3rd club (81 happiness) and 3rd person with 2nd club (78 happiness).
4+4+81+78 = 167
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted