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 n positive integers p0,p1,…,pn−1, where p0 is the initial price of the product and pi is how the price was increased during the i-th month.
Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase pi to the price at the start of this month (p0+p1+⋯+pi−1).
Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values pi in such a way, that all pi remain integers and the inflation coefficients for each month don't exceed k %.
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 k %?
你拥有一组表示某商品价格变化的统计数据,其形式为一个包含 n 个正整数的数组 p0,p1,…,pn−1,其中 p0 是该商品的初始价格,pi 表示第 i 个月的价格上涨额。
利用这些价格变化数据,你需要计算每个月的通货膨胀系数,其定义为当月价格上涨额 pi 与当月月初价格(即 p0+p1+⋯+pi−1)的比值。
你的老板明确要求:所有月份的通货膨胀系数不得超过 k %。因此,你决定对部分 pi 的值进行增加(所有 pi 必须保持为整数),使得每月的通货膨胀系数均不超过 k %。
你知道:改动幅度越大,作弊行为越明显。因此,你需要最小化所有改动量的总和。
为使所有通货膨胀系数均不超过 k %,所需的最小总改动量是多少?
输入格式
The first line contains a single integer t (1≤t≤1000) — the number of test cases.
The first line of each test case contains two integers n and k (2≤n≤100; 1≤k≤100) — the length of array p and coefficient k.
The second line of each test case contains n integers p0,p1,…,pn−1 (1≤pi≤109) — the array p.
第一行包含一个整数 t(1≤t≤1000)—— 测试用例的数量。
每个测试用例的第一行包含两个整数 n 和 k(2≤n≤100;1≤k≤100)—— 数组 p 的长度和系数 k。
每个测试用例的第二行包含 n 个整数 p0,p1,…,pn−1(1≤pi≤109)—— 数组 p。
输出格式
For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.
对于每个测试用例,输出使所有通货膨胀系数均不超过 k % 所需的最小总调整量。
输入输出样例
输入#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 p0 by 50 and p1 by 49 and get array [20150,50,202,202]. Then you get the next inflation coefficients:
- 2015050≤1001;
- 20150+50202≤1001;
- 20200+202202≤1001;
In the second test case, you don't need to modify array p, since the inflation coefficients are already good:
- 11≤100100;
- 1+11≤100100;
在第一个测试用例中,例如,你可以将 p0 增加 50,将 p1 增加 49,从而得到数组 [20150,50,202,202]。此时可得如下通货膨胀系数:
- 2015050≤1001;
- 20150+50202≤1001;
- 20200+202202≤1001;
在第二个测试用例中,无需修改数组 p,因为当前的通货膨胀系数已满足要求:
- 11≤100100;
- 1+11≤100100;
输入解题思路,AI测评打分。不知道怎么写?