Submission #887391

#TimeUsernameProblemLanguageResultExecution timeMemory
887391dubabubaLet's Win the Election (JOI22_ho_t3)C++14
0 / 100
441 ms1048580 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> void ono_min(T &MIN, T CMP) { if(CMP < MIN) MIN = CMP; } template<typename T> void ono_max(T &MAX, T CMP) { if(CMP > MAX) MAX = CMP; } const int mxn = 550; int n, m, a[mxn], b[mxn]; double dp[mxn][mxn][mxn]; double solve(int help) { // cout << "help: " << help << '\n'; for(int i = 0; i < mxn; i++) for(int j = 0; j < mxn; j++) for(int k = 0; k < mxn; k++) dp[i][j][k] = 1e9; dp[0][0][0] = 0.0; for(int i = 0; i < n; i++) for(int j = 0; j < n && j < m; j++) for(int k = 0; k <= j && k < help; k++) { ono_min(dp[i + 1][j][k], dp[i][j][k]); ono_min(dp[i + 1][j + 1][k], dp[i][j][k] + 1.0 * a[i] / (1.0 + k)); if(b[i] != -1) ono_min(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1.0 * b[i] / (1.0 + k)); } return dp[n][m][help]; } int main() { cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; double ans = 1e9; for(int help = 0; help <= n; help++) ono_min(ans, solve(help)); cout << ans << '\n'; 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...