#include <bits/stdc++.h>
using namespace std;
#ifdef Ramzi
#include "debug.h"
#else
#define debug(...)
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<pair<int, int>> v;
multiset<pair<int, int>> s;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
s.insert({a, b});
v.emplace_back(b, a);
}
sort(v.begin(), v.end());
double ans = 1e9;
for (int i = 0; i <= k; i++) {
multiset<pair<int, int>> se = s;
double sum = 0;
int l = 0, x = 0;
while (l < n && x < i) {
if (v[l].first != -1) {
sum += v[l].first;
se.erase(se.find({v[l].second, v[l].first}));
x += 1;
}
l += 1;
}
int y = k - x;
double res = 0;
while (y--) {
res += se.begin()->first;
se.erase(se.begin());
}
sum += res / (x + 1);
ans = min(ans, sum);
}
cout << fixed << setprecision(10) << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |