| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1302094 | daotuankhoi | Let's Win the Election (JOI22_ho_t3) | C++20 | 473 ms | 4416 KiB |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
template <class T> bool ckmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template <class T> bool ckmin(T &a, T b) { return a > b ? (a = b, true) : false; }
#define ld long double
const int MAXN = 505;
ld dp[MAXN][MAXN];
pair<int, int> a[MAXN];
int n, k;
ld calc(int fix) {
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= k - fix; j++) {
dp[i][j] = 1e9;
}
}
dp[0][0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= min(i, k - fix); j++) {
int sb = i - j - 1;
if (j) {
/// pick a
ckmin(dp[i][j], dp[i - 1][j - 1] + (ld)a[i].se / (fix + 1));
}
ckmin(dp[i][j], dp[i - 1][j] + (sb < fix ? (ld)a[i].fi / (sb + 1) : 0));
}
}
return dp[n][k - fix];
}
int main() {
#define NAME "test"
if (fopen(NAME".inp", "r")) {
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i].se >> a[i].fi;
a[i].fi = a[i].fi == -1 ? 1e9 : a[i].fi;
}
sort(a + 1, a + n + 1);
ld ans = 1e9;
for (int i = 0; i <= k; i++) ckmin(ans, calc(i));
cout << fixed << setprecision(15) << ans << '\n';
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... | ||||
