-
Notifications
You must be signed in to change notification settings - Fork 0
/
Inflation.cpp
56 lines (43 loc) · 948 Bytes
/
Inflation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// https://codeforces.com/problemset/problem/1476/B
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
ll n, k;
cin >> n >> k;
ll p[n];
ll sum = 0;
double coeff;
ll cost = 0;
for(ll i=0; i<n; i++)
{
cin >> p[i];
if(i>0)
{
coeff = ( (double)p[i]/sum ) * 100;
// cout << "p[i] = " << p[i] << "\n";
// cout << "sum = " << sum << "\n";
// cout << "coeff = " << coeff << "\n";
if(coeff > k)
{
double x = ceil((( (double)p[i]*100 ) / k) - sum);
cost += x;
p[0] += x;
sum += x;
}
}
sum += p[i];
}
cout << cost << "\n";
}
int main()
{
ll test;
cin >> test;
while(test--)
{
solve();
}
return 0;
}