Submission #1135328

#TimeUsernameProblemLanguageResultExecution timeMemory
1135328ramzialoulouLet's Win the Election (JOI22_ho_t3)C++20
0 / 100
2596 ms328 KiB
#include <bits/stdc++.h> using namespace std; #ifdef Ramzi #include "debug.h" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } double ans = 1e9; for (int i = 0; i < (1 << n); i++) { double sum = 0; int x = 0; multiset<pair<int, int>> s(a.begin(), a.end()); for (int j = 0; j < n; j++) { if (i & (1 << j) && x < k) { if (a[j].second != -1) { x += 1; sum += a[j].second; s.erase(s.find(a[j])); } } } debug(sum, x); int y = k - x; double res = 0; while (y--) { res += s.begin()->first; s.erase(s.begin()); } sum += res / (x + 1); ans = min(ans, sum); } cout << fixed << setprecision(10) << 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...