CF175C.Geometry Horse

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

瓦西娅正在玩《几何马》游戏。

游戏的目标是摧毁游戏世界中的几何图形。摧毁每个图形所获得的分数取决于该图形的类型以及当前的因子值。

共有 nn 种几何图形。对每种图形类型 ii,已知其数量 kik_i 和单个图形的基础分值 cic_i。摧毁一个类型为 ii 的图形可获得 ci⋅fc_i \cdot f 分,其中 ff 是当前因子值。因子值可以是 11 到 t+1t+1(含端点)之间的任意整数。游戏开始时因子值为 11。每当摧毁了 pip_i(1≤i≤t1 \le i \le t)个图形后,因子值即被设为 i+1i+1;因此第 (pi+1)(p_i + 1) 个被摧毁的图形将按因子值 i+1i+1 计分。

你的任务是计算:在瓦西娅摧毁所有图形的前提下,他所能获得的最大总分数。请注意,瓦西娅实力超群,可以以任意顺序摧毁图形。

输入格式

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 ≤ 109, 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 ≤ 1012), 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.

第一行包含一个整数 $ n (( 1 \leq n \leq 100 $)—— 图形种类的数量。

接下来的 $ n $ 行中,每行包含两个整数 $ k_i $ 和 $ c_i (( 1 \leq k_i \leq 10^9 ,, 0 \leq c_i \leq 1000 $),以空格分隔 —— 分别表示第 $ i $ 种图形的数量及其单个图形的成本。

下一行包含一个整数 $ t (( 1 \leq t \leq 100 $)—— 描述因子变化次数的数值。

再下一行包含 $ t $ 个整数 $ p_i (( 1 \leq p_1 < p_2 < \dots < p_t \leq 10^{12} $),以空格分隔。

请注意:在 C++ 中读取或写入 64 位整数时,请勿使用 %lld 格式说明符。推荐使用 cin、cout 流,或 %I64d 格式说明符。

输出格式

Print the only number — the maximum number of points Vasya can get.

输出唯一的一个数字——Vasya 能获得的最高分数。

输入输出样例

  • 输入#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.

在第一个例子中,瓦西娅首先摧毁了三个图形,获得 3⋅1⋅10=303 \cdot 1 \cdot 10 = 30 分;随后倍率变为 22,再摧毁剩余两个图形可获得 2⋅2⋅10=402 \cdot 2 \cdot 10 = 40 分。最终瓦西娅共获得 7070 分。

在第二个例子中,全部 88 个图形均在倍率为 11 时被摧毁,因此瓦西娅获得 (3⋅8+5⋅10)⋅1=74(3 \cdot 8 + 5 \cdot 10) \cdot 1 = 74 分。

输入解题思路,AI测评打分。不知道怎么写?

首页