Submission #924256

#TimeUsernameProblemLanguageResultExecution timeMemory
924256OAleksaLet's Win the Election (JOI22_ho_t3)C++14
11 / 100
2597 ms5340 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define int long long const int N = 550; int n, x; pair<int, int> a[N]; double dp1[N][N], dp2[N][N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { cin >> n >> x; for (int i = 1;i <= n;i++) { cin >> a[i].f >> a[i].s; if (a[i].s == -1) a[i].s = 1e9; } sort(a + 1, a + n + 1, [&](pair<int, int> x, pair<int, int> y) { return x.s < y.s; }); //prvih i, dobio sam j glasova, k ljudi ucestvuje double ans = 1e9; for (int s = 1;s <= n;s++) { for (int j = 0;j <= n;j++) { for (int k = 0;k <= n;k++) dp1[j][k] = 1e9; } dp1[0][1] = 0; for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) { for (int k = 1;k <= n;k++) { dp2[j][k] = dp1[j][k]; dp2[j][k] = min(dp2[j][k], dp1[j - 1][k] + (double)a[i].f / s); if (k > 1) dp2[j][k] = min(dp2[j][k], dp1[j - 1][k - 1] + (double)a[i].s / (k - 1)); } } swap(dp1, dp2); } ans = min(ans, dp1[x][s]); } cout << fixed << setprecision(15) << ans; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...