Submission #785039

#TimeUsernameProblemLanguageResultExecution timeMemory
785039gun_ganLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
9 ms376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 505; int N, K; int a[MX], b[MX]; 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; } double ans = 1e9; for(int x = 0; x <= min(K, tot); x++) { double res = 0; vector<int> ord; for(int i = 1; i <= N; i++) ord.push_back(i); sort(ord.begin(), ord.end(), [&](auto x, auto y) { return b[x] > b[y]; }); int cnt = 1; for(int i = 0; i < x; i++) { res += (double) b[ord.back()] / cnt; ord.pop_back(); cnt++; } sort(ord.begin(), ord.end(), [&](auto x, auto y) { return a[x] > a[y]; }); for(int i = 0; i < K - x; i++) { res += (double) a[ord.back()] / cnt; ord.pop_back(); } ans = min(ans, res); } 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...