제출 #1135322

#제출 시각아이디문제언어결과실행 시간메모리
1135322ramzialoulouLet's Win the Election (JOI22_ho_t3)C++20
5 / 100
7 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>> v; multiset<pair<int, int>> s; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; s.insert({a, b}); v.emplace_back(b, a); } sort(v.begin(), v.end()); double ans = 1e9; for (int i = 0; i <= k; i++) { multiset<pair<int, int>> se = s; double sum = 0; int l = 0, x = 0; while (l < n && x < i) { if (v[l].first != -1) { sum += v[l].first; se.erase(se.find({v[l].second, v[l].first})); x += 1; } l += 1; } int y = k - x; double res = 0; while (y--) { res += se.begin()->first; se.erase(se.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...