#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x,0,sizeof(x))
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
// It doesn't matter how Slowly you go,as long as you do not stop.
// What is my Aim:->(SELF SATISFACTION that I have done my BEST).
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://x...content-available-to-author-only...i.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
// This is used when We want to use pairs in unordered_map and unordered_set
struct pair_hash
{
template <class T1, class T2>
std::size_t operator() (const std::pair<T1, T2> &pair) const
{
return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
}
};
bool check(ll mid, ll arr[], ll n, ll pre[], ll k)
{
for(ll i=1;i<n;i++)
{
ll curr_prefix= pre[i-1] + mid;
if((double)curr_prefix/arr[i]>=(double)100/k)
continue;
else
return false;
}
return true;
}
int main() {
auto start = chrono::high_resolution_clock::now();
fio;
ll t=1;
cin>>t;
while(t--)
{
ll n,k; cin>>n>>k;
ll arr[n]; rep(i,0,n) cin>>arr[i];
ll pre[n];
pre[0]=arr[0];
for(int i=1;i<n;i++)
pre[i]=pre[i-1] + arr[i];
ll low=0;
ll high=1e18;
while(low<high)
{
ll mid = (low) + (high-low)/2;
if(check(mid,arr,n,pre,k))
high=mid;
else
low=mid;
if(high-low==1) break;
}
if(check(low,arr,n,pre,k))
cout<<low<<"\n";
else
cout<<high<<"\n";
}
auto finish = chrono::high_resolution_clock::now();
cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPiAKI2luY2x1ZGUgPGV4dC9wYl9kcy90cmVlX3BvbGljeS5ocHA+CnVzaW5nIG5hbWVzcGFjZSBfX2dudV9wYmRzOyAKI2RlZmluZSBmaW8gaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoTlVMTCk7IGNvdXQudGllKE5VTEwpOwojcHJhZ21hIEdDQyBvcHRpbWl6ZSAidHJhcHYiCiNkZWZpbmUgX0dMSUJDWFhfREVCVUcKI2RlZmluZSBsbCBsb25nIGxvbmcgaW50CiNkZWZpbmUgbGQgbG9uZyBkb3VibGUKI2RlZmluZSB1bGwgdW5zaWduZWQgbG9uZyBsb25nIGludCAgLy8gcmFuZ2VzIGZyb20gKDAgLSB0d2ljZSBvZiBsb25nIGxvbmcgaW50KQojZGVmaW5lIHJlcChpLGEsbikgZm9yIChsbCBpPWE7aTxuO2krKykKI2RlZmluZSBwZXIoaSxhLG4pIGZvciAobGwgaT1uLTE7aT49YT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