Advertisement
Guest User

Untitled

a guest
Dec 4th, 2021
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define ll          long long
  3. #define epsilon 0.000000001
  4. using namespace std;
  5. ll n , k ;
  6. vector<ll>arr;
  7.  
  8. bool check(long double mid){
  9.  
  10.     ll cnt = 0 ;
  11.     for(ll i = 1 ; i <= n ; i++){
  12.         cnt+=arr[i]/mid;
  13.     }
  14.     return cnt>=k ;
  15.  
  16. }
  17.  
  18.  
  19. int main()
  20. {
  21. cin>> n >> k ;
  22. arr.assign(n+1,0);
  23. for(int i =  1 ; i <= n ; i++){
  24.     cin >> arr[i];
  25. }
  26. double lo = 0 , hi = 1e15;
  27. long double mid ;
  28. while(hi-lo>=epsilon){
  29.      mid = (lo+hi)/2;
  30.      if(check(mid)){
  31.         lo = mid ;
  32.      }else{
  33.         hi = mid ;
  34.      }
  35.  
  36. }
  37. cout << lo ;
  38. }
  39.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement