Submission #825955

#TimeUsernameProblemLanguageResultExecution timeMemory
825955vjudge1Let's Win the Election (JOI22_ho_t3)C++17
100 / 100
902 ms396 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ld INF = 1e18; int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n, k; cin >> n >> k; pair<ld, ld> c[n + 1]; for(int i = 1; i <= n; i++) { cin >> c[i].first >> c[i].second; if(c[i].second == -1) c[i].second = INF; } sort(c + 1, c + n + 1, [](pair<ld, ld> x, pair<ld, ld> y){return x.second < y.second;}); ld res = INF; for(int t = 0; t <= k; t++) { vector<ld> dp(k - t + 1, INF); dp[0] = 0; for(int i = 1; i <= n; i++) { vector<ld> newdp(k - t + 1, INF); for(int j = 0; j <= k - t; j++) { if(j) newdp[j] = min(newdp[j], dp[j - 1] + c[i].first / (t + 1)); if(i - j <= t) newdp[j] = min(newdp[j], dp[j] + c[i].second / (i - j)); else newdp[j] = min(newdp[j], dp[j]); } dp = newdp; } res = min(res, dp[k - t]); } cout << setprecision(9) << fixed << res; }
#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...