# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624443 | QwertyPi | Let's Win the Election (JOI22_ho_t3) | C++14 | 1 ms | 308 KiB |
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 N = 513;
int a[N], b[N], s[N];
struct Pair{
int a, b;
Pair() = default;
Pair(int _a, int _b) : a(_a), b(_b){};
};
vector<Pair> vp;
int main(){
int n, k;
cin >> n >> k;
for(int i = 0; i < n; i++){
cin >> a[i] >> b[i];
vp.push_back({a[i], b[i] == -1 ? 1e9 : b[i]});
}
sort(vp.begin(), vp.end(), [](Pair x, Pair y){
return x.b < y.b;
});
for(int i = 0; i < n; i++){
s[i + 1] = s[i] + vp[i].a;
}
long double ans = 1e9;
for(int i = 0; i <= k; i++){
long double res = 0;
for(int j = 0; j < i; j++){
res += (long double) vp[j].b / (j + 1);
}
res += (long double) (s[k] - s[i]) / (i + 1);
ans = min(ans, res);
}
cout << fixed << setprecision(15) << ans << endl;
}
Compilation message (stderr)
# | 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... |