Submission #528144

#TimeUsernameProblemLanguageResultExecution timeMemory
528144dooweyLet's Win the Election (JOI22_ho_t3)C++14
10 / 100
10 ms356 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ld; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int N = 505; int main(){ fastIO; //freopen("in.txt","r",stdin); int n, k; cin >> n >> k; vector<pair<ld,ld>> C(n); for(int i = 0 ; i < n; i ++ ){ cin >> C[i].se >> C[i].fi; if(C[i].fi == -1) C[i].fi = (ld)1000000; } sort(C.begin(), C.end()); ld S0 = 0; ld res = (ld)1e8; ld S; for(int i = 0 ; i <= k ; i ++ ){ if(i) S0 += (C[i - 1].fi / ld(i)); vector<ld> A; for(int j = i; j < n; j ++ ){ A.push_back(C[j].se); } sort(A.begin(), A.end()); S = 0; for(int j = 0; j < k - i; j ++ ){ S += A[j] / ld(i + 1); } res = min(res, S + S0); } cout << fixed << setprecision(9) << res << "\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...