Submission #795729

#TimeUsernameProblemLanguageResultExecution timeMemory
7957291binLet's Win the Election (JOI22_ho_t3)C++14
32 / 100
187 ms2320 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const int NMAX = 1e5 + 5; const int inf = 1e6; const double eps = 1e-10; int n, k, a, b; double dp[505][505]; vector<pair<int, int>> v; double solve(int x){ double ret = 0; for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j] = 1e9; dp[0][0] = 0; for(int i = 1; i <= n; i++){ auto&[b, a] = v[i - 1]; for(int j = 0; j <= min(i, x); j++){ dp[i][j] = dp[i - 1][j] + 1.0 * a / (x + 1); if(j && b != inf) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1.0 * b / j); } } if(dp[n][x] > 1e9 - eps) return 1e9; vector<double> t; int j = x; for(int i = n; i; i--){ auto&[b, a] = v[i - 1]; if(abs(dp[i][j] - dp[i - 1][j] - 1.0 * a / (x + 1)) < eps) t.emplace_back(1.0 * a / (x + 1)); else ret += dp[i][j] - dp[i - 1][j - 1], j--; } sort(all(t)); for(int i = 0; i < k - x; i++) ret += t[i]; return ret; } int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for(int i = 0; i < n; i++){ cin >> a >> b; if(b == -1) b = inf; v.emplace_back(b, a); } sort(all(v)); double ans = inf; for(int i = 0; i <= k; i++) ans = min(ans, solve(i)); cout << fixed << setprecision(10) << ans; return 0; }

Compilation message (stderr)

Main.cpp: In function 'double solve(int)':
Main.cpp:20:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |         auto&[b, a] = v[i - 1];
      |              ^
Main.cpp:30:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |         auto&[b, a] = v[i - 1];
      |              ^
#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...