Submission #1288333

#TimeUsernameProblemLanguageResultExecution timeMemory
1288333tunademayoLet's Win the Election (JOI22_ho_t3)C++20
0 / 100
69 ms18844 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double const bool Multitest = 0; const int N = 505; const ll offset = 1e9; int n, k; struct Type { ld x, y; }; Type a[N], b[N]; bool cmp1(Type a, Type b) { return a.y < b.y || (a.y == b.y && a.x < b.x); } namespace sub345 { const int M = 105; ld dp[M][M][M]; void minimize(ld& a, ld b) { a = min(a, b); } ld solve() { for(int i = 0 ; i <= n ; i++) { for(int j = 0 ; j <= n ; j++) { for(int cnt = 0 ; cnt <= n ; cnt++) { dp[i][j][cnt] = 1e9; } } } // sort(a + 1, a + 1 + n, cmp1); dp[0][0][1] = 0; for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j <= i && j <= k; j++) { for(int cnt = 1 ; cnt <= j + 1 ; cnt++) { minimize(dp[i + 1][j + 1][cnt], dp[i][j][cnt] + (a[i + 1].x / cnt)); minimize(dp[i + 1][j + 1][cnt + 1], dp[i][j][cnt] + (a[i + 1].y / cnt)); minimize(dp[i + 1][j][cnt], dp[i][j][cnt]); // cout << i << ' ' << j << ' ' << cnt << ' ' << dp[i][j][cnt] << " ---> " << dp[i + 1][j + 1][cnt] << '\n'; } } // cout << dp[i][4][1] << '\n'; } ld ans = 1e18; // cout << dp[4][4][1 ] << '\n'/ for(int x = 1 ; x <= k + 1 ; x++) minimize(ans, dp[n][k][x]); return ans; } } void work() { cin >> n >> k; for(int i = 1 ; i <= n ; i++) { cin >> a[i].x >> a[i].y; if(a[i].y == -1) a[i].y = 50; b[i] = a[i]; } ld ans = 1e18; vector<int> v; for(int i = 1 ; i <= n ; i++) v.push_back(i); do { for(int i = 1 ; i <= n ; i++) { a[i] = b[v[i - 1]]; } // ?cout << sub345::solve() << '\n'; ans = min(ans, sub345::solve()); } while(next_permutation(v.begin(), v.end())); cout << setprecision(9) << fixed << ans ; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int q = 1; if(Multitest) cin >> q; while(q--) work(); }
#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...