fork download
  1. // ORZVANH14
  2. //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣤⣤⣤⣤⣶⣦⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀
  3. //⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⡿⠛⠉⠙⠛⠛⠛⠛⠻⢿⣿⣷⣤⡀⠀⠀⠀⠀⠀
  4. //⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠋⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⠈⢻⣿⣿⡄⠀⠀⠀⠀
  5. //⠀⠀⠀⠀⠀⠀⠀⣸⣿⡏⠀⠀⠀⣠⣶⣾⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣄⠀⠀⠀
  6. //⠀⠀⠀⠀⠀⠀⠀⣿⣿⠁⠀⠀⢰⣿⣿⣯⠁⠀⠀⠀⠀⠀⠀⠀⠈⠙⢿⣷⡄⠀
  7. //⠀⠀⣀⣤⣴⣶⣶⣿⡟⠀⠀⠀⢸⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⠀
  8. //⠀⢰⣿⡟⠋⠉⣹⣿⡇⠀⠀⠀⠘⣿⣿⣿⣿⣷⣦⣤⣤⣤⣶⣶⣶⣶⣿⣿⣿⠀
  9. //⠀⢸⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠀
  10. //⠀⣸⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠉⠻⠿⣿⣿⣿⣿⡿⠿⠿⠛⢻⣿⡇⠀⠀
  11. //⠀⣿⣿⠁⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣧⠀⠀
  12. //⠀⣿⣿⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀
  13. //⠀⣿⣿⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀
  14. //⠀⢿⣿⡆⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀
  15. //⠀⠸⣿⣧⡀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠃⠀⠀
  16. //⠀⠀⠛⢿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⣰⣿⣿⣷⣶⣶⣶⣶⠶⠀⢠⣿⣿⠀⠀⠀
  17. //⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⣿⣿⡇⠀⣽⣿⡏⠁⠀⠀⢸⣿⡇⠀⠀⠀
  18. //⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⣿⣿⡇⠀⢹⣿⡆⠀⠀⠀⣸⣿⠇⠀⠀⠀
  19. //⠀⠀⠀⠀⠀⠀⠀⢿⣿⣦⣄⣀⣠⣴⣿⣿⠁⠀⠈⠻⣿⣿⣿⣿⡿⠏⠀⠀⠀⠀
  20. //⠀⠀⠀⠀⠀⠀⠀⠈⠛⠻⠿⠿⠿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. #include <bits/stdc++.h>
  30.  
  31. using namespace std;
  32.  
  33. #define int long long
  34. #define ld long double
  35. #define pb push_back
  36. #define fi first
  37. #define se second
  38. #define nn '\n'
  39. #define pi pair<ll,ll>
  40. #define unmp unordered_map
  41. #define uns unordered_set
  42. #define lb lower_bound
  43. #define ub upper_bound
  44. #define pq priority_queue
  45. #define q queue
  46. #define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  47. #define TASK " "
  48. int mod = 1e9+7;
  49. const int N = 2*1e5 + 5;
  50. int MOD = 998244353;
  51. int bit[200000];
  52. int n, k;
  53. ld a[N];
  54. bool anhphucbell(ld mid){
  55. int hehe = 0;
  56. for(int i = 1; i <= n; i++){
  57. hehe += a[i] / mid;
  58. }
  59. return hehe >= k;
  60. }
  61. signed main(){
  62. ios_base::sync_with_stdio(0);
  63. cin.tie(0);
  64. cout.tie(0);
  65. if(fopen(TASK".INP","r")){
  66. freopen(TASK".INP","r",stdin);
  67. freopen(TASK".OUT","w",stdout);
  68. }
  69. cin >> n >> k;
  70. for(int i = 1; i <= n; i++){
  71. cin >> a[i];
  72. }
  73. ld l = 0, r = 1e7, kq = -1;
  74. while(r - l > 1e-6){
  75. ld mid = (l + r) / 2;
  76. if(anhphucbell(mid)){
  77. l = mid;
  78. }
  79. else{
  80. r = mid;
  81. }
  82.  
  83. }
  84. cout << fixed << setprecision(1) << l << nn;
  85. return 0;
  86. }
  87.  
Success #stdin #stdout 0.01s 5796KB
stdin
21 64
9624508
7983982
3034554
1376090
8578637
2470520
5277268
9213657
7439757
8233018
1939708
9045358
1688807
601752
3425465
940652
4493948
6625634
867251
5204123
785381
stdout
1325126.8