fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. signed main(){
  4. int n, k;
  5. cin >> n >> k;
  6. vector<int> a(n);
  7. for(int i = 0; i < n; i++){
  8. cin >> a[i];
  9. }
  10. double l = 1, r = 1e7;
  11. double ans = 0;
  12. for(int i = 0; i < 60; i++){
  13. double mid = (l + r) * 0.5;
  14. int now = 0;
  15. for(int j = 0; j < a.size(); j++){
  16. if((int)a[j] / mid < 1){
  17. now = 0;
  18. break;
  19. }
  20. now += a[j] / mid;
  21.  
  22. }
  23. if(now >= k){
  24. l = mid;
  25. ans = max(ans, mid);
  26. }else{
  27. r = mid;
  28. }
  29.  
  30. }
  31. cout << fixed << setprecision(15) << ans;
  32. }
Success #stdin #stdout 0s 5280KB
stdin
1 1
7
stdout
6.999999999996483