# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824380 | peteza | Let's Win the Election (JOI22_ho_t3) | C++14 | 3 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
bool vis[505];
int n, k;
long double as, bs;
vector<pair<int, int>> a, b;
int todo=0,ptr=0;
long double ans = 1e18, csum = 0;
int main() {
cin >> n >> k;
for(int i=0;i<n;i++) {
cin >> as >> bs;
a.emplace_back(as, i);
b.emplace_back(bs==-1 ? INT_MAX :bs, i);
}
sort(a.begin(), a.end()); sort(b.begin(), b.end());
for(int selb=0;selb<=b.size();selb++) {
vector<bool> vis(n, 0);
todo = k; csum = 0; ptr = 0;
bool broke = 0;
for(int i=0;i<selb;i++) {
if(b[i].first == INT_MAX) broke = 1;
vis[b[i].second] = 1;
csum += b[i].first/(i+1); todo--;
}
if(broke) break;
while(ptr<n&&todo > 0){
if(vis[a[ptr].second]){ptr++; continue;}
csum += a[ptr].first/(selb+1);
todo--; ptr++;
}
if(todo<=0) ans = min(ans, csum);
}
cout << fixed << setprecision(20) << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |