#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define len(v) (int)((v).size())
const int inf = 1e9;
inline void solve(){
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; ++i){
		cin >> a[i] >> b[i];
	}
	vector<int> inds2(n);
	for (int i = 0; i < n; ++i){
		inds2[i] = i;
	}
	sort(inds2.begin(), inds2.end(), [&](int i, int j){
		if (a[i] != a[j]) return a[i] < a[j];
		else return b[i] > b[j];
	});
	ld ans = 1e100;
	for (int h = 0; h <= n; ++h){
		vector<int> inds;
		for (int i = h; i < n; ++i){
			inds.push_back(inds2[i]);
		}
		for (int j = 0; j < h; ++j){
			inds.push_back(inds2[j]);
		}
		sort(inds.begin(), inds.end(), [&](int i, int j){
			if (b[i] == -1 && b[j] == -1) return false;
			if (b[i] == -1 || b[j] == -1) return b[i] != -1;
			return b[i] < b[j];
		});
		for (int i = 0; i <= n; ++i){
			if (i > 0 && b[inds[i - 1]] == -1) break;
			ld time = 0;
			for (int j = 0; j < i; ++j){
				time += b[inds[j]] / (ld)(j + 1);
			}
			vector<ll> rm;
			for (int j = i; j < n; ++j){
				rm.push_back(a[inds[j]]);
			}
			sort(rm.begin(), rm.end());
			for (int j = 0; j < k - i; ++j){
				time += rm[j] / (ld)(i + 1);
			}
			ans = min(ans, time);
		}
	}
	cout << ans << '\n';
}
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(60);
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}
| # | 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... |