A8540 | Geometry Horse
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya plays the Geometry Horse.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are $n$ types of geometric figures. The number of figures of type $k_{i}$ and figure cost $c_{i}$ is known for each figure type. A player gets $c_{i}·f$ points for destroying one figure of type $i$ , where $f$ is the current factor. The factor value can be an integer number from $1$ to $t+1$ , inclusive. At the beginning of the game the factor value is equal to 1. The factor is set to $i+1$ after destruction of $p_{i}$ $(1<=i<=t)$ figures, so the $(p_{i}+1)$ -th figure to be destroyed is considered with factor equal to $i+1$ .
Your task is to determine the maximum number of points Vasya can get after he destroys all figures. Take into account that Vasya is so tough that he can destroy figures in any order chosen by him.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are $n$ types of geometric figures. The number of figures of type $k_{i}$ and figure cost $c_{i}$ is known for each figure type. A player gets $c_{i}·f$ points for destroying one figure of type $i$ , where $f$ is the current factor. The factor value can be an integer number from $1$ to $t+1$ , inclusive. At the beginning of the game the factor value is equal to 1. The factor is set to $i+1$ after destruction of $p_{i}$ $(1<=i<=t)$ figures, so the $(p_{i}+1)$ -th figure to be destroyed is considered with factor equal to $i+1$ .
Your task is to determine the maximum number of points Vasya can get after he destroys all figures. Take into account that Vasya is so tough that he can destroy figures in any order chosen by him.
输入格式
The first line contains the only integer number $n$ $(1<=n<=100)$ — the number of figure types.
Each of the following $n$ lines contains two integer numbers $k_{i}$ and $c_{i}$ $(1<=k_{i}<=10^{9},0<=c_{i}<=1000)$ , separated with space — the number of figures of the $i$ -th type and the cost of one $i$ -type figure, correspondingly.
The next line contains the only integer number $t$ $(1<=t<=100)$ — the number that describe the factor's changes.
The next line contains $t$ integer numbers $p_{i}$ $(1<=p_{1}<p_{2}<...<p_{t}<=10^{12})$ , separated with spaces.
Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.
Each of the following $n$ lines contains two integer numbers $k_{i}$ and $c_{i}$ $(1<=k_{i}<=10^{9},0<=c_{i}<=1000)$ , separated with space — the number of figures of the $i$ -th type and the cost of one $i$ -type figure, correspondingly.
The next line contains the only integer number $t$ $(1<=t<=100)$ — the number that describe the factor's changes.
The next line contains $t$ integer numbers $p_{i}$ $(1<=p_{1}<p_{2}<...<p_{t}<=10^{12})$ , separated with spaces.
Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.
输出格式
Print the only number — the maximum number of points Vasya can get.
输入输出样例
输入 #1
1 5 10 2 3 6
输出 #1
70
输入 #2
2 3 8 5 10 1 20
输出 #2
74
In the first example Vasya destroys three figures first and gets $3·1·10=30$ points. Then the factor will become equal to $2$ and after destroying the last two figures Vasya will get $2·2·10=40$ points. As a result Vasya will get $70$ points.
In the second example all $8$ figures will be destroyed with factor $1$ , so Vasya will get $(3·8+5·10)·1=74$ points.
In the second example all $8$ figures will be destroyed with factor $1$ , so Vasya will get $(3·8+5·10)·1=74$ points.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted