# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991637 | Otalp | Let's Win the Election (JOI22_ho_t3) | C++14 | 2585 ms | 4792 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;
#define ll long long
#define int ll
#define pii pair<int, int>
#define ff first
#define ss second
#define ld long double
#define pb push_back
pair<ld, ld> a[300100];
ll b[300100];
ll n, m;
ll us[200100];
bool cmp(int x, int y){
return a[x].ss < a[y].ss;
}
void solve(){
cin>>n>>m;
int cnt = 0;
vector<int> q;
for(int i=1; i<=n; i++){
cin>>a[i].ff>>a[i].ss;
if(a[i].ss == -1) a[i].ss = 1e9;
else cnt ++, q.pb(i);
}
sort(a + 1, a + 1 + n);
ld ans = 1e18;
for(int k=0; k<(1 << n); k++){
ld res = 0;
vector<int> q;
for(int i=0; i<n; i++){
us[i + 1] = 0;
if((k & (1 << i))){
q.pb(i + 1);
if(a[i + 1].ss == 1e9) res = -1;
}
}
if(res == -1) continue;
sort(q.begin(), q.end());
for(int i=0; i<q.size(); i++){
us[q[i]] = 1;
res += a[q[i]].ss / (i + 1);
}
int cnt = q.size();
for(int i=1; i<=n; i++){
if(cnt >= m) break;
if(us[i]) continue;
us[i] = 1;
res += a[i].ff / (q.size() + 1);
cnt ++;
}
ans = min(ans, res);
}
cout<<fixed<<setprecision(9)<<ans<<'\n';
}
signed main(){
solve();
}
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... |