This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int nx=505;
#define int long double
int n, k;
vector<pair<int, int>> v;
int cost, res=LDBL_MAX;
int32_t main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>k;
v.resize(n);
for (int i=0; i<n; i++)
{
cin>>v[i].second>>v[i].first;
v[i].second=-v[i].second;
if (v[i].first==-1) v[i].first=1e9;
}
sort(v.begin(), v.end());
for (int i=0; i<k; i++)
{
vector<int> t;
for (int j=i; j<n; j++) t.push_back(-v[j].second);
sort(t.begin(), t.end());
int tmp=cost;
//cout<<tmp<<'\n';
for (int j=0; j<k-i; j++) tmp+=(t[j])/(1+i);
//cout<<i<<' '<<tmp<<'\n';
res=min(res, tmp);
cost+=(v[i].first)/(1+i);
}
cout<<fixed<<setprecision(12)<<res;
}
# | 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... |