Submission #529470

#TimeUsernameProblemLanguageResultExecution timeMemory
529470wiwihoLet's Win the Election (JOI22_ho_t3)C++14
11 / 100
216 ms460 KiB
#include <bits/stdc++.h> #define iter(a) a.begin(), a.end() #define mp make_pair #define F first #define S second #define eb emplace_back #define lsort(a) sort(iter(a)) #define gsort(a) sort(iter(a), greater<>()) using namespace std; typedef long long ll; typedef double ld; using pii = pair<int, int>; ll iceil(ll a, ll b){ return (a + b - 1) / b; } int n, k; vector<int> a, b; vector<ld> tans; ld calc(int cnt){ vector<ld> dp(cnt + 1, 1e87); dp[0] = 0; for(int i = 1; i <= n; i++){ for(int c1 = cnt; c1 >= 0; c1--){ if(dp[c1] != 1e87) dp[c1] += (ld)a[i] / (cnt + 1); if(c1 > 0) dp[c1] = min(dp[c1], dp[c1 - 1] + (ld)b[i] / c1); } } //cerr << "calc " << cnt << " " << dp[cnt][k - cnt] << "\n"; return dp[cnt]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; a.resize(n + 1); b.resize(n + 1); tans.resize(k + 1, 1e99); vector<pii> tmp(n + 1); int c = 0; for(int i = 1; i <= n; i++){ cin >> tmp[i].F >> tmp[i].S; if(tmp[i].S != -1) c++; } sort(tmp.begin() + 1, tmp.end(), [&](pii a, pii b){ return a.S < b.S; }); for(int i = 1; i <= n; i++) a[i] = tmp[i].F, b[i] = tmp[i].S; ld ans = 1e87; for(int i = 0; i <= c; i++) ans = min(ans, calc(i)); cout << fixed << setprecision(20) << ans << "\n"; return 0; }
#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...