Submission #785055

#TimeUsernameProblemLanguageResultExecution timeMemory
785055gun_ganLet's Win the Election (JOI22_ho_t3)C++17
56 / 100
179 ms9428 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 105; int N, K; int a[MX], b[MX]; double dp[MX][MX][MX]; vector<pair<int, int>> v; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> N >> K; int tot = 0; for(int i = 1; i <= N; i++) { cin >> a[i] >> b[i]; if(b[i] != -1) tot++; else b[i] = 1e9; v.push_back({b[i], a[i]}); } sort(v.begin(), v.end()); double ans = 1e9; for(int x = 0; x <= min(K, tot); x++) { // fixed collaborator for(int i = 0; i < MX; i++) for(int j = 0; j < MX; j++) for(int k = 0; k < MX; k++) dp[i][j][k] = 1e9; dp[0][0][0] = 0; for(int i = 0; i < N; i++) { for(int j = 0; j <= N; j++) { // votes for(int k = 0; k <= N; k++) { // num of collaborator if(dp[i][j][k] == 1e9) continue; // skip dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]); // ambil vote dp[i + 1][j + 1][k] = min(dp[i + 1][j + 1][k], dp[i][j][k] + (double) v[i].second / (x + 1)); // ambil collaborator if(v[i].first != 1e9) dp[i + 1][j + 1][k + 1] = min(dp[i + 1][j + 1][k + 1], dp[i][j][k] + (double) v[i].first / (k + 1)); } } } ans = min(ans, dp[N][K][x]); } cout << fixed << setprecision(15) << ans << '\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...