A14504 | The Strongest Build
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Ivan is playing yet another roguelike computer game. He controls a single hero in the game. The hero has $n$ equipment slots. There is a list of $c_i$ items for the $i$ -th slot, the $j$ -th of them increases the hero strength by $a_{i,j}$ . The items for each slot are pairwise distinct and are listed in the increasing order of their strength increase. So, $a_{i,1} < a_{i,2} < \dots < a_{i,c_i}$ .
For each slot Ivan chooses exactly one item. Let the chosen item for the $i$ -th slot be the $b_i$ -th item in the corresponding list. The sequence of choices $[b_1, b_2, \dots, b_n]$ is called a build.
The strength of a build is the sum of the strength increases of the items in it. Some builds are banned from the game. There is a list of $m$ pairwise distinct banned builds. It's guaranteed that there's at least one build that's not banned.
What is the build with the maximum strength that is not banned from the game? If there are multiple builds with maximum strength, print any of them.
For each slot Ivan chooses exactly one item. Let the chosen item for the $i$ -th slot be the $b_i$ -th item in the corresponding list. The sequence of choices $[b_1, b_2, \dots, b_n]$ is called a build.
The strength of a build is the sum of the strength increases of the items in it. Some builds are banned from the game. There is a list of $m$ pairwise distinct banned builds. It's guaranteed that there's at least one build that's not banned.
What is the build with the maximum strength that is not banned from the game? If there are multiple builds with maximum strength, print any of them.
输入格式
The first line contains a single integer $n$ ( $1 \le n \le 10$ ) — the number of equipment slots.
The $i$ -th of the next $n$ lines contains the description of the items for the $i$ -th slot. First, one integer $c_i$ ( $1 \le c_i \le 2 \cdot 10^5$ ) — the number of items for the $i$ -th slot. Then $c_i$ integers $a_{i,1}, a_{i,2}, \dots, a_{i,c_i}$ ( $1 \le a_{i,1} < a_{i,2} < \dots < a_{i,c_i} \le 10^8$ ).
The sum of $c_i$ doesn't exceed $2 \cdot 10^5$ .
The next line contains a single integer $m$ ( $0 \le m \le 10^5$ ) — the number of banned builds.
Each of the next $m$ lines contains a description of a banned build — a sequence of $n$ integers $b_1, b_2, \dots, b_n$ ( $1 \le b_i \le c_i$ ).
The builds are pairwise distinct, and there's at least one build that's not banned.
The $i$ -th of the next $n$ lines contains the description of the items for the $i$ -th slot. First, one integer $c_i$ ( $1 \le c_i \le 2 \cdot 10^5$ ) — the number of items for the $i$ -th slot. Then $c_i$ integers $a_{i,1}, a_{i,2}, \dots, a_{i,c_i}$ ( $1 \le a_{i,1} < a_{i,2} < \dots < a_{i,c_i} \le 10^8$ ).
The sum of $c_i$ doesn't exceed $2 \cdot 10^5$ .
The next line contains a single integer $m$ ( $0 \le m \le 10^5$ ) — the number of banned builds.
Each of the next $m$ lines contains a description of a banned build — a sequence of $n$ integers $b_1, b_2, \dots, b_n$ ( $1 \le b_i \le c_i$ ).
The builds are pairwise distinct, and there's at least one build that's not banned.
输出格式
Print the build with the maximum strength that is not banned from the game. If there are multiple builds with maximum strength, print any of them.
输入输出样例
输入 #1
3 3 1 2 3 2 1 5 3 2 4 6 2 3 2 3 3 2 2
输出 #1
2 2 3
输入 #2
3 3 1 2 3 2 1 5 3 2 4 6 2 3 2 3 2 2 3
输出 #2
1 2 3
输入 #3
3 3 1 2 3 2 1 5 3 2 4 6 2 3 2 3 2 2 3
输出 #3
3 2 2
输入 #4
4 1 10 1 4 1 7 1 3 0
输出 #4
1 1 1 1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted