Submission #536806

#TimeUsernameProblemLanguageResultExecution timeMemory
536806xp875Let's Win the Election (JOI22_ho_t3)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll u = 10000; int main() { ll n, k; cin >> n >> k; ll a[n], b[n]; vector<ll> h, nh; for(int i=0; i<n; i++) { cin >> a[i] >> b[i]; if(b[i]==-1) nh.push_back(a[i]); else h.push_back(a[i]); } sort(h.begin(), h.end()); sort(nh.begin(), nh.end()); ll ans = (ll)1<<60; for(int i=0; i<min(k, (ll)h.size()); i++) { if((ll)h.size()+i<k) continue; ll tot = 0, helper = 1; for(int j=0; j<i; j++) { tot += h[j]*u/helper; //cout << h[j] << ' ' << helper << '\n'; helper ++; } for(int j=i;j<k; j++) { tot += nh[j-i]*u/helper; //cout << nh[j-i] << '\n'; } ans = min(tot, ans); } cout << (double)ans/u; }
#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...