Submission #863806

#TimeUsernameProblemLanguageResultExecution timeMemory
863806prairie2022Let's Win the Election (JOI22_ho_t3)C++17
10 / 100
5 ms756 KiB
#include<bits/stdc++.h> typedef long double ld; #define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0); using namespace std; #define F first #define S second int main(){ fastio const int big = 1e6; int n, k; ld ans = big; cin >> n >> k; vector<pair<int, int>> ba(n); for(int i=0; i<n; i++){ cin >> ba[i].S >> ba[i].F; if(ba[i].F==-1) ba[i].F = big; } sort(ba.begin(), ba.end()); for(int i=0; i<=k; i++){ if(i && ba[i-1].F==big) break; ld tmp = 0; for(int j=0; j<i; j++) tmp += ((ld)ba[j].F)/(1+j); vector<int> rem(n-i); for(int j=i; j<n; j++) rem[j-i] = ba[j].S; sort(rem.begin(), rem.end()); int hr = 0; for(int j=0; j<k-i; j++) hr += rem[j]; tmp += ((ld)hr)/(1+i); ans = min(ans, tmp); } cout << fixed << setprecision(6) << 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...