fork download
  1. #include <bits/stdc++.h>
  2. # define IO ios_base::sync_with_stdio(),cin.tie(0),cout.tie(0) ;
  3. # define ll long long
  4. using namespace std ;
  5. const int sz = 1e5 + 4 ;
  6. int t, n, k, a[sz] ;
  7. bool ok (ll mid)
  8. {
  9. ll pre = mid + a[1] ;
  10. bool yes = 1 ;
  11. for(int i=2 ; i <= n ; i++)
  12. {
  13. if(100LL * a[i] > 1LL * k * pre)
  14. yes = 0 ;
  15. pre += a[i] ;
  16. }
  17. return (yes == 1) ;
  18. }
  19. int main()
  20. {
  21. IO ;
  22. cin>>t ;
  23. while(t--)
  24. {
  25. cin>>n>>k ;
  26. for(int i=1 ; i <= n ; i++)
  27. {
  28. cin>>a[i] ;
  29. }
  30. ll st = 0 , en = 1e15 , mid ;
  31. while(st < en)
  32. {
  33. mid = (st + en) / 2 ;
  34. if(ok(mid))
  35. en = mid ;
  36. else
  37. st = mid + 1 ;
  38. }
  39. cout<<st<<'\n' ;
  40. }
  41. return 0 ;
  42. }
  43.  
  44.  
  45.  
Success #stdin #stdout 0.01s 5536KB
stdin
Standard input is empty
stdout
Standard output is empty