Submission #888075

#TimeUsernameProblemLanguageResultExecution timeMemory
888075HakiersLet's Win the Election (JOI22_ho_t3)C++17
100 / 100
1014 ms4696 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ld; constexpr int MAXN = 5e2 + 8; constexpr ld oo = 2e10; ld dp[MAXN][MAXN]; pair<ld, ld> T[MAXN]; int n, k; ld check(ld m){ for(int i = 0; i <= n; i++) for(int j = 0; j <= k; j++) dp[i][j] = oo; dp[0][0] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j <= min(k-(int)m, i); j++){ //dokladamy A //if(j < i) dp[i][j] = min(dp[i][j], (j?(dp[i-1][j-1] + (T[i].second/(m+1)): oo)); //dokladamy B //dp[i][j] = (dp[i-1][j] + (T[i].first/min((ld)(i-j), m+1))); //min((j?(dp[i-1][j-1] + T[i].second/(m+1)): oo), ((i-j)?(dp[i-1][j] + T[i].first/min((ld)(i-j), m+1)): oo)); //dokladamy A dp[i][j+1] = min(dp[i][j+1], dp[i-1][j] + (T[i].second/(m+1))); //dokladamy B if(i-j) dp[i][j] = min(dp[i][j], dp[i-1][j] + ((i-j <= m)? (T[i].first/min((ld)(i-j), m+1)):0)); } } return dp[n][k-(int)m]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++){ ld a, b; cin >> a >> b; if(b == -1) b = oo; T[i] = {b, a}; } sort(T+1, T+1+n); ld best = oo; for(int i = 0; i <= (k-1); i++) best = min(best, check(i)); cout << fixed << setprecision(9) << best << "\n"; }
#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...