fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define nl '\n'
  4. #define ll long long int
  5.  
  6. using namespace std;
  7.  
  8. //* Use this for USACO Problems
  9. void setIO(string s)
  10. {
  11. freopen((s + ".in").c_str(), "r", stdin);
  12. freopen((s + ".out").c_str(), "w", stdout);
  13. }
  14.  
  15. int n, k;
  16. vector<int> v;
  17.  
  18. bool test(double x)
  19. {
  20. int s = 0;
  21. for (int e : v)
  22. s += floor(e / x);
  23. return s >= k;
  24. }
  25.  
  26. int main()
  27. {
  28. // setIO("circlecross");
  29. ios_base::sync_with_stdio(0);
  30. cin.tie(0);
  31. cout.tie(0);
  32. int t = 1;
  33. // cin >> t;
  34.  
  35. while (t--)
  36. {
  37. cin >> n >> k;
  38. v.resize(n);
  39. for (int i = 0; i < n; i++)
  40. {
  41. cin >> v[i];
  42. }
  43. double l = 0;
  44. double r = 1e8;
  45.  
  46. for (int i = 0; i < 64; i++)
  47. {
  48. double m = (l + r) / 2;
  49. if (test(m))
  50. {
  51. l = m;
  52. }
  53. else
  54. {
  55. r = m;
  56. }
  57. }
  58. cout << setprecision(20) << l << nl;
  59. }
  60. }
  61.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
100000000