Submission #785044

#TimeUsernameProblemLanguageResultExecution timeMemory
785044gun_ganLet's Win the Election (JOI22_ho_t3)C++17
28 / 100
2571 ms324 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; for(int i = 0; i < N; i++) { cin >> a[i] >> b[i]; } double ans = 1e9; for(int i = 0; i < (1 << N); i++) { bool can = 1; for(int j = 0; j < N; j++) { if((i >> j & 1) && b[j] == -1) can = 0; } if(!can) continue; double res = 0; int cnt = 1; vector<int> v; for(int j = 0; j < N; j++) { if(i >> j & 1) v.push_back(b[j]); } sort(v.begin(), v.end()); for(auto x : v) { res += (double) x / cnt; cnt++; } if(cnt > K) continue; v.clear(); for(int j = 0; j < N; j++) { if(!(i >> j & 1)) v.push_back(a[j]); } sort(v.begin(), v.end()); for(int i = 0; i < K - cnt + 1; i++) { res += (double) v[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...