| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1337009 | wedonttalkanymore | Let's Win the Election (JOI22_ho_t3) | C++20 | 65 ms | 456 KiB |
#include <bits/stdc++.h>
// #include <coin.h>
/*
Chang ki si xuyen man dem
Di lac vao trong giac mong
*/
using namespace std;
using ll = long long;
#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second
const ll N = 5e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19;
int n, k;
struct item {
int x, y;
};
item a[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
if (fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].y;
if (a[i].y == -1) a[i].y = inf;
}
sort(a + 1, a + n + 1, [](item x, item y) {
if (x.y == y.y) return x.x > y.x;
return x.y < y.y;
});
for (int i = 1; i <= n; i++) cout << a[i].x << ' ' << a[i].y << '\n';
double ans = 1e18;
for (int i = 1; i <= k; i++) {
vector <double> dp(n + 1, inf);
dp[0] = 0.0;
for (int j = 1; j <= n; j++) {
for (int x = j - 1; x >= 0; x--) {
int t = j - x;
dp[x + 1] = min(dp[x + 1], dp[x] + a[j].x * 1.0 / i);
if (t < i) {
if (a[j].y != -1) dp[x] += a[j].y * 1.0 / t;
else dp[x] = inf;
}
}
}
ans = min(ans, dp[k - i + 1]);
}
cout << 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... | ||||
