# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638717 | jamezzz | Let's Win the Election (JOI22_ho_t3) | C++17 | 10 ms | 320 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 fi first
#define se second
#define sf scanf
#define pf printf
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
#define maxn 505
#define INF 1023456789
int n,k,a[maxn],b[maxn];
bool have[maxn];
vector<ii> v;
ld memo[maxn][maxn];
int main(){
sf("%d%d",&n,&k);
for(int i=0;i<n;++i){
int x,y;
sf("%d%d",&x,&y);
if(y==-1)y=INF;
v.push_back({x,y});
}
sort(v.begin(),v.end(),[](ii &a,ii &b){
if(a.se==b.se)return a.fi>b.fi;
else return a.se<b.se;
});
int num=0;
for(int i=0;i<n;++i){
tie(a[i],b[i])=v[i];
if(b[i]!=INF)++num;
}
ld ans=INF;
for(int ppl=0;ppl<=num;++ppl){
ld cur=0;
for(int i=0;i<ppl;++i){
cur+=((ld)b[i])/((ld)i+1);
}
priority_queue<int,vector<int>,greater<int>> pq;
for(int i=ppl;i<n;++i)pq.push(a[i]);
for(int i=0;i<k-ppl;++i){
cur+=((ld)pq.top())/((ld)ppl+1);
pq.pop();
}
ans=min(ans,cur);
}
pf("%Lf\n",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... |