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>
#define int long long
using namespace std;
struct oras
{
int a, b;
};
oras v[100005];
typedef long double ld;
bool cmp2(oras a, oras b)
{
return a.a < b.a;
}
bool cmp1(oras a, oras b)
{
return a.b < b.b;
}
signed main()
{
int n, k;
cin>>n>>k;
ld minn = 0.0;
int nrr = n;
for(int i = 1; i <= n; i++)
{
cin>>v[i].a>>v[i].b, minn += (ld)v[i].a;
if(v[i].b == -1) v[i].b = 1e12, nrr--;
}
for(int cnt = 0; cnt <= min(nrr, k); cnt++)
{
sort(v + 1, v + n + 1, cmp1);
ld rez = 0.0;
for(int i = 1; i <= cnt; i++)
rez += (ld)((ld)v[i].b / (ld)i);
sort(v + min(n + 1, cnt + 1), v + n + 1, cmp2);
for(int i = cnt + 1; i <= k; i++)
rez += (ld)((ld)v[i].a / (ld)(cnt + 1));
minn = min(minn, rez);
}
cout<<fixed<<setprecision(15);
cout<<minn;
return 0;
}
# | 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... |