Submission #924313

#TimeUsernameProblemLanguageResultExecution timeMemory
924313OAleksaLet's Win the Election (JOI22_ho_t3)C++14
56 / 100
2572 ms1007696 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define int long long const int N = 510; int n, x; pair<int, int> a[N]; double dp[N][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 i = 0;i <= n;i++) { for (int j = 0;j <= n;j++) { for (int k = 0;k <= n;k++) dp[i][j][k] = 1e9; } } for (int i = 0;i <= n;i++) dp[i][0][1] = 0; for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) { if (i == j) { for (int k = 1;k <= n;k++) { dp[i][j][k] = dp[i - 1][j][k]; dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][k] + (double)a[i].f / s); if (k > 1) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][k - 1] + (double)a[i].s / (k - 1)); } } else { dp[i][j][s] = min(dp[i][j][s], dp[i - 1][j][s]); dp[i][j][s] = min(dp[i][j][s], dp[i - 1][j - 1][s] + (double)a[i].f / s); } } } ans = min(ans, dp[n][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...