# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
848331 | SUNWOOOOOOOO | Let's Win the Election (JOI22_ho_t3) | C++17 | 115 ms | 2592 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 mxN = 505;
array <int, 2> A[mxN]; // {B, A}
double dp[mxN][mxN]; // current state, no of selected collabs
int n, k;
void dpinit()
{
for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j] = 2e9;
}
int main()
{
scanf("%d %d", &n, &k);
for (int i = 1; i <= n; i++) scanf("%d %d", &A[i][1], &A[i][0]);
sort(A + 1, A + n + 1);
// n == k
double ans = 2e9;
for (int x = 0; x <= n; x++){ // number of collabs
dpinit();
dp[0][0] = 0;
for (int i = 1; i <= n; i++){
for (int j = 0; j <= min(i, x); j++){
double val = 2e9;
if (j) val = min(val, dp[i - 1][j - 1] + 1.0 * A[i][0] / j);
val = min(val, dp[i - 1][j] + 1.0 * A[i][1] / (x + 1));
dp[i][j] = val;
}
}
ans = min(ans, dp[n][x]);
}
printf("%lf\n", ans);
return 0;
}
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... |