Submission #891768

#TimeUsernameProblemLanguageResultExecution timeMemory
89176812345678Let's Win the Election (JOI22_ho_t3)C++17
10 / 100
6 ms600 KiB
#include <bits/stdc++.h> using namespace std; const int nx=505; double n, k, a[nx], b[nx], cnt, c[nx]; double tmp, ans=DBL_MAX; vector<pair<double, int>> v; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>k; for (int i=1; i<=n; i++) cin>>a[i]>>b[i], cnt+=(b[i]!=-1), v.push_back({(b[i]==-1)?1e9:b[i], i}); sort(v.begin(), v.end()); for (int i=0; i<=min(cnt, k); i++) { double res=0; vector<double> t; for (int j=1; j<=n; j++) if (!c[j]) t.push_back(a[j]); sort(t.begin(), t.end()); for (int j=0; j+1+i<=k; j++) res+=(((double)t[j])/(i+1)); ans=min(ans, tmp+res); if (i!=k) tmp+=(v[i].first)/(i+1), c[v[i].second]=1; } printf("%.10f", ans); }
#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...