#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define fi first
#define dd long double
#define se second
const int N = 5e2 + 5, M = 1e9 + 7, LG = 20;
int n , A[N] , k;
dd x , y;
void solve(){
cin >> n >> k;
int u = 0;
vector<pair<dd,dd>> s;
vector<pair<dd,dd>> t;
for (int i=1 ; i<=n ; i++){
cin >> x >> y;
if (y>=0){
s.pb({y,i});
u++;
}
t.pb({x,i});
}
sort(s.begin(),s.end());
sort(t.begin(),t.end());
dd ans = 1e9;
for (int i=0 ; i<=u ; i++){
dd cr = 0 , cm = 1;
int y = k;
bool vi[N] = {};
for (int j=0 ; j<i ; j++){
cr += (s[j].fi/cm);
vi[(int)(s[j].se)] = 1;
cm++;
y--;
if (y<=0) break;
}
for (int j=0 ; j<n ; j++){
if (y<=0) break;
if (!vi[(int)(t[j].se)]){
// if (i==1) cout << cm << ' ';
cr += (t[j].fi/cm);
y--;
}
}
ans = min(ans , cr);
}
cout << ans << endl;
}
signed main(){
// freopen("" , "r" , stdin);
// freopen("" , "w" , stdout);
cout << setprecision(30);
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int ts = 1;
// cin >> ts;
while(ts--){
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... |