# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863840 | prairie2022 | Let's Win the Election (JOI22_ho_t3) | C++17 | 378 ms | 548 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>
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());
if(n>20) return 0;
for(int mask = 0; mask<(1<<n); mask++){
bool flag = 0;
vector<int> b, a;
for(int i=0; i<n; i++){
if(mask&(1<<i)){
if(ba[i].F==big){
flag = 1;
break;
}
b.push_back(ba[i].F);
}
else a.push_back(ba[i].S);
}
if(flag || b.size()>=k) break;
sort(a.begin(), a.end());
ld tmp = 0;
for(int i=0; i<b.size(); i++)
tmp += ((ld)b[i])/(1+i);
for(int i=0; i<k-b.size(); i++){
tmp += ((ld)a[i])/(1+b.size());
}
ans = min(tmp, ans);
}
cout << fixed << setprecision(6) << ans << '\n';
return 0;
}
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... |