CF1476B.Inflation

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have a statistic of price changes for one product represented as an array of nn positive integers p0,p1,…,pn−1p_0, p_1, \dots, p_{n - 1}, where p0p_0 is the initial price of the product and pip_i is how the price was increased during the ii-th month.

Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase pip_i to the price at the start of this month (p0+p1+⋯+pi−1)(p_0 + p_1 + \dots + p_{i - 1}).

Your boss said you clearly that the inflation coefficients must not exceed kk %, so you decided to increase some values pip_i in such a way, that all pip_i remain integers and the inflation coefficients for each month don't exceed kk %.

You know, that the bigger changes — the more obvious cheating. That's why you need to minimize the total sum of changes.

What's the minimum total sum of changes you need to make all inflation coefficients not more than kk %?

你拥有一组表示某商品价格变化的统计数据,其形式为一个包含 nn 个正整数的数组 p0,p1,…,pn−1p_0, p_1, \dots, p_{n - 1},其中 p0p_0 是该商品的初始价格,pip_i 表示第 ii 个月的价格上涨额。

利用这些价格变化数据,你需要计算每个月的通货膨胀系数,其定义为当月价格上涨额 pip_i 与当月月初价格(即 p0+p1+⋯+pi−1p_0 + p_1 + \dots + p_{i - 1})的比值。

你的老板明确要求:所有月份的通货膨胀系数不得超过 kk %。因此,你决定对部分 pip_i 的值进行增加(所有 pip_i 必须保持为整数),使得每月的通货膨胀系数均不超过 kk %。

你知道:改动幅度越大,作弊行为越明显。因此,你需要最小化所有改动量的总和。

为使所有通货膨胀系数均不超过 kk %,所需的最小总改动量是多少?

输入格式

The first line contains a single integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases.

The first line of each test case contains two integers nn and kk (2≤n≤1002 \le n \le 100; 1≤k≤1001 \le k \le 100) — the length of array pp and coefficient kk.

The second line of each test case contains nn integers p0,p1,…,pn−1p_0, p_1, \dots, p_{n - 1} (1≤pi≤1091 \le p_i \le 10^9) — the array pp.

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例的第一行包含两个整数 nn 和 kk(2≤n≤1002 \le n \le 100;1≤k≤1001 \le k \le 100)—— 数组 pp 的长度和系数 kk。

每个测试用例的第二行包含 nn 个整数 p0,p1,…,pn−1p_0, p_1, \dots, p_{n - 1}(1≤pi≤1091 \le p_i \le 10^9)—— 数组 pp。

输出格式

For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than kk %.

对于每个测试用例,输出使所有通货膨胀系数均不超过 kk % 所需的最小总调整量。

输入输出样例

  • 输入#1

    2
    4 1
    20100 1 202 202
    3 100
    1 1 1

    输出#1

    99
    0

说明/提示

In the first test case, you can, for example, increase p0p_0 by 5050 and p1p_1 by 4949 and get array [20150,50,202,202][20150, 50, 202, 202]. Then you get the next inflation coefficients:

  1. 5020150≤1100\frac{50}{20150} \le \frac{1}{100};
  2. 20220150+50≤1100\frac{202}{20150 + 50} \le \frac{1}{100};
  3. 20220200+202≤1100\frac{202}{20200 + 202} \le \frac{1}{100};

In the second test case, you don't need to modify array pp, since the inflation coefficients are already good:

  1. 11≤100100\frac{1}{1} \le \frac{100}{100};
  2. 11+1≤100100\frac{1}{1 + 1} \le \frac{100}{100};

在第一个测试用例中,例如,你可以将 p0p_0 增加 5050,将 p1p_1 增加 4949,从而得到数组 [20150,50,202,202][20150, 50, 202, 202]。此时可得如下通货膨胀系数:

  1. 5020150≤1100\frac{50}{20150} \le \frac{1}{100};
  2. 20220150+50≤1100\frac{202}{20150 + 50} \le \frac{1}{100};
  3. 20220200+202≤1100\frac{202}{20200 + 202} \le \frac{1}{100};

在第二个测试用例中,无需修改数组 pp,因为当前的通货膨胀系数已满足要求:

  1. 11≤100100\frac{1}{1} \le \frac{100}{100};
  2. 11+1≤100100\frac{1}{1 + 1} \le \frac{100}{100};

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

首页