A11686 | Well played!
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:
Max owns $n$ creatures, $i$ -th of them can be described with two numbers — its health $hp_{i}$ and its damage $dmg_{i}$ . Max also has two types of spells in stock:
1. Doubles health of the creature ( $hp_{i}$ := $hp_{i}·2$ );
2. Assigns value of health of the creature to its damage ( $dmg_{i}$ := $hp_{i}$ ).
Spell of first type can be used no more than $a$ times in total, of the second type — no more than $b$ times in total. Spell can be used on a certain creature multiple times. Spells can be used in arbitrary order. It isn't necessary to use all the spells.
Max is really busy preparing for his final exams, so he asks you to determine what is the maximal total damage of all creatures he can achieve if he uses spells in most optimal way.
Max owns $n$ creatures, $i$ -th of them can be described with two numbers — its health $hp_{i}$ and its damage $dmg_{i}$ . Max also has two types of spells in stock:
1. Doubles health of the creature ( $hp_{i}$ := $hp_{i}·2$ );
2. Assigns value of health of the creature to its damage ( $dmg_{i}$ := $hp_{i}$ ).
Spell of first type can be used no more than $a$ times in total, of the second type — no more than $b$ times in total. Spell can be used on a certain creature multiple times. Spells can be used in arbitrary order. It isn't necessary to use all the spells.
Max is really busy preparing for his final exams, so he asks you to determine what is the maximal total damage of all creatures he can achieve if he uses spells in most optimal way.
输入格式
The first line contains three integers $n$ , $a$ , $b$ ( $1<=n<=2·10^{5}$ , $0<=a<=20$ , $0<=b<=2·10^{5}$ ) — the number of creatures, spells of the first type and spells of the second type, respectively.
The $i$ -th of the next $n$ lines contain two number $hp_{i}$ and $dmg_{i}$ ( $1<=hp_{i},dmg_{i}<=10^{9}$ ) — description of the $i$ -th creature.
The $i$ -th of the next $n$ lines contain two number $hp_{i}$ and $dmg_{i}$ ( $1<=hp_{i},dmg_{i}<=10^{9}$ ) — description of the $i$ -th creature.
输出格式
Print single integer — maximum total damage creatures can deal.
输入输出样例
输入 #1
2 1 1 10 15 6 1
输出 #1
27
输入 #2
3 0 3 10 8 7 11 5 2
输出 #2
26
In the first example Max should use the spell of the first type on the second creature, then the spell of the second type on the same creature. Then total damage will be equal to $15+6·2=27$ .
In the second example Max should use the spell of the second type on the first creature, then the spell of the second type on the third creature. Total damage will be equal to $10+11+5=26$ .
In the second example Max should use the spell of the second type on the first creature, then the spell of the second type on the third creature. Total damage will be equal to $10+11+5=26$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted