#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool cmp(pair<double,double> a,pair<double,double> b){
return a.second==b.second?a.first<b.first:a.second<b.second;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n,k;
cin >> n >> k;
vector<pair<double,double> > dat(n);
for (int i = 0;i<n;i++){
cin >> dat[i].first >> dat[i].second;
if (dat[i].second<0) dat[i].second = 100000000;
}
double ans = 1000000;
for (int i = 0;i<k;i++){
double t = 0;
sort(dat.begin(),dat.end(),cmp);
for (int j = 0;j<i;j++){
t += dat[j].second/(j+1);
}
sort(dat.begin()+i,dat.end());
for (int j = i;j<k;j++){
t += dat[j].first/(i+1);
}
ans = min(ans,t);
}
cout << fixed << setprecision(15) << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
5 ms |
204 KB |
Output is correct |
8 |
Correct |
8 ms |
320 KB |
Output is correct |
9 |
Correct |
9 ms |
204 KB |
Output is correct |
10 |
Correct |
5 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
5 ms |
204 KB |
Output is correct |
8 |
Correct |
8 ms |
320 KB |
Output is correct |
9 |
Correct |
9 ms |
204 KB |
Output is correct |
10 |
Correct |
5 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
6 ms |
320 KB |
Output is correct |
13 |
Correct |
7 ms |
204 KB |
Output is correct |
14 |
Correct |
7 ms |
320 KB |
Output is correct |
15 |
Correct |
9 ms |
204 KB |
Output is correct |
16 |
Correct |
13 ms |
320 KB |
Output is correct |
17 |
Correct |
10 ms |
204 KB |
Output is correct |
18 |
Correct |
10 ms |
204 KB |
Output is correct |
19 |
Correct |
14 ms |
204 KB |
Output is correct |
20 |
Correct |
10 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
5 ms |
204 KB |
Output is correct |
8 |
Correct |
8 ms |
320 KB |
Output is correct |
9 |
Correct |
9 ms |
204 KB |
Output is correct |
10 |
Correct |
5 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
6 ms |
320 KB |
Output is correct |
13 |
Correct |
7 ms |
204 KB |
Output is correct |
14 |
Correct |
7 ms |
320 KB |
Output is correct |
15 |
Correct |
9 ms |
204 KB |
Output is correct |
16 |
Correct |
13 ms |
320 KB |
Output is correct |
17 |
Correct |
10 ms |
204 KB |
Output is correct |
18 |
Correct |
10 ms |
204 KB |
Output is correct |
19 |
Correct |
14 ms |
204 KB |
Output is correct |
20 |
Correct |
10 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
0 ms |
204 KB |
Output is correct |
26 |
Correct |
0 ms |
204 KB |
Output is correct |
27 |
Correct |
0 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |