Submission #526598

#TimeUsernameProblemLanguageResultExecution timeMemory
526598hmm789Let's Win the Election (JOI22_ho_t3)C++14
10 / 100
706 ms984680 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; pair<int, int> a[n]; for(int i = 0; i < n; i++) { cin >> a[i].second >> a[i].first; if(a[i].first == -1) a[i].first = 1e9; } sort(a, a+n); double dp[n+1][k+1][k+1]; for(int i = 0; i <= n; i++) { for(int j = 0; j <= k; j++) { for(int m = 0; m <= k; m++) { if(m == 0 && i == 0 && j == 0) dp[i][j][m] = 0; else if(i == 0 || i < m || i < j || m < j) dp[i][j][m] = 1e9; else if(m == 0) dp[i][j][m] = 0; else if(j == 0) dp[i][j][m] = min(dp[i-1][j][m-1] + a[i-1].second*1.0/(j+1), dp[i-1][j][m]); else dp[i][j][m] = min(dp[i-1][j][m-1] + a[i-1].second*1.0/(j+1), min(dp[i-1][j-1][m-1] + a[i-1].first*1.0/j, dp[i-1][j][m])); } } } double res = 1e9; for(int i = 0; i <= k; i++) res = min(res, dp[n][i][k]); cout << fixed << setprecision(5) << res; }
#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...