Submission #824429

#TimeUsernameProblemLanguageResultExecution timeMemory
824429petezaLet's Win the Election (JOI22_ho_t3)C++14
11 / 100
2593 ms994508 KiB
#include <bits/stdc++.h> using namespace std; int n, k; bool vis[505][505][505]; double DP[505][505][505], inf = 1e12, cans = inf; pair<int, int> dat[505]; int main() { DP[0][0][0] = 0; vis[0][0][0] = 1; cin >> n >> k; int bc = n; for(int i=0;i<n;i++) { cin >> dat[i].first >> dat[i].second; if(dat[i].second == -1) bc--, dat[i].second = INT_MAX; } sort(dat, dat+n); double frfr = 1e12; do { for(int i=0;i<=n;i++) { for(int j=0;j<=k;j++) { for(int K=0;K<=bc;K++) { if(i == j && j == K && !i) continue; if(i == 0 || j<K) {DP[i][j][K] = inf; continue;} DP[i][j][K] = DP[i-1][j][K]; if(j) DP[i][j][K] = min(DP[i][j][K], DP[i-1][j-1][K] + (1.00*dat[i-1].first/(K+1))); if(j && K && dat[i-1].second != INT_MAX) DP[i][j][K] = min(DP[i][j][K], DP[i-1][j-1][K-1] + (1.00*dat[i-1].second/K)); } } } for(int i=0;i<=bc;i++) cans = min(cans, DP[n][k][i]); frfr = min(frfr, cans); } while (next_permutation(dat, dat+n)); cout << frfr; }
#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...