Submission #785053

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