-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeRopes.cpp
More file actions
48 lines (34 loc) · 754 Bytes
/
Copy pathcodeRopes.cpp
File metadata and controls
48 lines (34 loc) · 754 Bytes
1
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Contest : ITMO Academy Pilot Course
* Problem : Ropes
* Link : https://codeforces.com/edu/course/2/lesson/6/2/practice/contest/283932/problem/B
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int n, k, v[11234];
bool isValid(double x) {
int cnt = 0;
for (int i = 0; i < n; i++) cnt += v[i] / x;
return cnt >= k;
}
double bs() {
double l = 0, r = 1e7, m, ans = 0;
for (int i = 0; i < 100; i++) {
m = (r + l) / 2;
if (isValid(m)) {
ans = m;
l = m;
} else
r = m;
}
return ans;
}
int main() {
fastio
scanf("%i%i", &n, &k);
for (int i = 0; i < n; i++) scanf("%i", &v[i]);
printf("%f", bs());
return 0;
}