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;
vector<int> List;
vector<int> List2;
int N,K,tmp,tmp2;
int main(){
cin>>N>>K;
for(int i=1;i<=N;i++){
cin>>tmp>>tmp2;
if(tmp2==-1) List.push_back(tmp);
else List2.push_back(tmp2);
}
sort(List.begin(),List.end());
sort(List2.begin(),List2.end());
double answer = 0;
double Min = 10000000000;
for(int i=0;i<=(int)List2.size();i++){
answer = 0;
if(((int)List.size()+i)<K) continue;
for(int j=0;j<i;j++){
answer += (double)List2[j]/(j+1);
}
for(int j=0;j<K-i;j++){
answer += (double)List[j]/(i+1);
//cout<<answer;
}
//cout<<answer<<"\n";
Min = min(Min,answer);
}
cout<<Min;
}
# | 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... |