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;
int n, k;
vector<pair<int, int>> v;
double cost, res=DBL_MAX;
int 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;
if (v[i].first==-1) v[i].first=1e9;
}
sort(v.begin(), v.end());
for (int i=0; i<n; i++)
{
vector<int> t;
for (int j=i; j<n; j++) t.push_back(v[j].second);
sort(t.begin(), t.end());
double tmp=cost;
//cout<<tmp<<'\n';
for (int j=0; j<k-i; j++) tmp+=((double)t[j])/(1+i);
//cout<<i<<' '<<tmp<<'\n';
res=min(res, tmp);
cost+=((double)v[i].first)/(1+i);
}
setprecision(8);
cout<<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... |