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;
ll u = 10000;
int main() {
ll n, k;
cin >> n >> k;
ll a[n], b[n];
vector<ll> h, nh;
for(int i=0; i<n; i++) {
cin >> a[i] >> b[i];
if(b[i]==-1) nh.push_back(a[i]);
else h.push_back(a[i]);
}
sort(h.begin(), h.end());
sort(nh.begin(), nh.end());
ll ans = (ll)1<<60;
for(int i=0; i<min(k, (ll)h.size()); i++) {
ll tot = 0, helper = 1;
for(int j=0; j<i; j++) {
tot += h[i]*u/helper;
helper ++;
}
for(int j=i;j<k; j++) {
tot += nh[i]*u/helper;
}
ans = min(tot, ans);
}
cout << (double)ans/u;
}
# | 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... |