A12578 | Destroy it!
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.
The boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c_i$ and damage $d_i$ . You may play some of your cards during each turn in some sequence (you choose the cards and the exact order they are played), as long as the total cost of the cards you play during the turn does not exceed $3$ . After playing some (possibly zero) cards, you end your turn, and all cards you didn't play are discarded. Note that you can use each card at most once.
Your character has also found an artifact that boosts the damage of some of your actions: every $10$ -th card you play deals double damage.
What is the maximum possible damage you can deal during $n$ turns?
The boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c_i$ and damage $d_i$ . You may play some of your cards during each turn in some sequence (you choose the cards and the exact order they are played), as long as the total cost of the cards you play during the turn does not exceed $3$ . After playing some (possibly zero) cards, you end your turn, and all cards you didn't play are discarded. Note that you can use each card at most once.
Your character has also found an artifact that boosts the damage of some of your actions: every $10$ -th card you play deals double damage.
What is the maximum possible damage you can deal during $n$ turns?
输入格式
The first line contains one integer $n$ ( $1 \le n \le 2 \cdot 10^5$ ) — the number of turns.
Then $n$ blocks of input follow, the $i$ -th block representing the cards you get during the $i$ -th turn.
Each block begins with a line containing one integer $k_i$ ( $1 \le k_i \le 2 \cdot 10^5$ ) — the number of cards you get during $i$ -th turn. Then $k_i$ lines follow, each containing two integers $c_j$ and $d_j$ ( $1 \le c_j \le 3$ , $1 \le d_j \le 10^9$ ) — the parameters of the corresponding card.
It is guaranteed that $\sum \limits_{i = 1}^{n} k_i \le 2 \cdot 10^5$ .
Then $n$ blocks of input follow, the $i$ -th block representing the cards you get during the $i$ -th turn.
Each block begins with a line containing one integer $k_i$ ( $1 \le k_i \le 2 \cdot 10^5$ ) — the number of cards you get during $i$ -th turn. Then $k_i$ lines follow, each containing two integers $c_j$ and $d_j$ ( $1 \le c_j \le 3$ , $1 \le d_j \le 10^9$ ) — the parameters of the corresponding card.
It is guaranteed that $\sum \limits_{i = 1}^{n} k_i \le 2 \cdot 10^5$ .
输出格式
Print one integer — the maximum damage you may deal.
输入输出样例
输入 #1
5 3 1 6 1 7 1 5 2 1 4 1 3 3 1 10 3 5 2 3 3 1 15 2 4 1 10 1 1 100
输出 #1
263
In the example test the best course of action is as follows:
During the first turn, play all three cards in any order and deal $18$ damage.
During the second turn, play both cards and deal $7$ damage.
During the third turn, play the first and the third card and deal $13$ damage.
During the fourth turn, play the first and the third card and deal $25$ damage.
During the fifth turn, play the only card, which will deal double damage ( $200$ ).
During the first turn, play all three cards in any order and deal $18$ damage.
During the second turn, play both cards and deal $7$ damage.
During the third turn, play the first and the third card and deal $13$ damage.
During the fourth turn, play the first and the third card and deal $25$ damage.
During the fifth turn, play the only card, which will deal double damage ( $200$ ).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted