# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890516 | irmuun | Let's Win the Election (JOI22_ho_t3) | C++17 | 1 ms | 348 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 pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,k;
cin>>n>>k;
ll a[n+5],b[n+5];
for(ll i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
vector<ll>v1,v2;
for(ll i=1;i<=n;i++){
if(b[i]==-1){
v1.pb(a[i]);
}
else{
v2.pb(a[i]);
}
}
sort(all(v1));
sort(all(v2));
double ans=1e18;
double cur=0;
for(ll i=0;i<=min((ll)v2.size(),k);i++){
if(i+v1.size()>=k){
double T=0;
for(ll j=0;j<k-i;j++){
T+=v1[j];
}
ans=min(ans,cur+(double)T/(i+1));
}
if(i<v2.size()){
cur+=(double)v2[i]/(i+1);
}
}
printf("%.10f",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... |