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;
typedef long long ll;
bool cmp(pair<double,double> a,pair<double,double> b){
return a.second==b.second?a.first<b.first:(a.second>=0&&(b.second<0||a.second<b.second));
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n,k;
cin >> n >> k;
vector<pair<double,double> > dat(n);
int l = n;
for (int i = 0;i<n;i++){
cin >> dat[i].first >> dat[i].second;
if (dat[i].second<0) l--;
}
double ans = 100000000;
for (int i = 0;i<min(k,l+1);i++){
double t = 0;
sort(dat.begin(),dat.end(),cmp);
for (int j = 0;j<i;j++){
t += dat[j].second/(j+1);
}
sort(dat.begin()+i,dat.end());
for (int j = i;j<k;j++){
t += dat[j].first/(i+1);
}
ans = min(ans,t);
}
cout << fixed << setprecision(15) << ans << "\n";
}
# | 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... |