제출 #1288412

#제출 시각아이디문제언어결과실행 시간메모리
1288412tunademayoLet's Win the Election (JOI22_ho_t3)C++20
0 / 100
657 ms1114112 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); } ld dp[N][N][N]; void minimize(ld& a, ld b) { if(a > b) a = b; } ld cal(int p) { for(int i = 0 ; i <= n ; i++) { for(int j = 0 ; j <= n ; j++) { for(int cnt = 0 ; cnt <= n + 1 ; cnt++) { dp[i][j][cnt] = 1e18; } } } dp[0][0][1] = 0; for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j <= k && j <= i ; j++) { for(int cnt = 1 ; cnt <= j + 1 ; cnt++) { minimize(dp[i + 1][j][cnt], dp[i][j][cnt]); minimize(dp[i + 1][j + 1][cnt], dp[i][j][cnt] + a[i + 1].x / p); minimize(dp[i + 1][j + 1][cnt + 1], dp[i][j][cnt] + a[i + 1].y / cnt); // cout << i << ' ' << j << ' ' << cnt << ' ' << dp[i][j][cnt] << '\n'; } } } return dp[n][k][p]; } 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 = 10000000; } sort(a + 1, a + 1 + n, cmp1); ld ans = 1e18; // cout << cal(6); ////// // return; // cout << i << ' ' << cal(i) << '\n'; // ans = min(ans, cal(1)); 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...