# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638711 | jamezzz | Let's Win the Election (JOI22_ho_t3) | C++17 | 993 ms | 4300 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 pf printf
#define sf scanf
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
#define maxn 505
#define INF (ld)(1000*n)
int n,k,a[maxn],b[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({y,x});
}
sort(v.begin(),v.end());
for(int i=0;i<n;++i){
tie(b[i],a[i])=v[i];
}
for(int i=0;i<=n+1;++i){
for(int j=0;j<=n+1;++j){
memo[i][j]=INF;
}
}
memo[0][0]=0;
for(int pos=0;pos<n;++pos){
for(int ppl=n;ppl>=0;--ppl){
for(int vote=n;vote>=0;--vote){
ld ans=memo[ppl][vote];
if(vote!=0)ans=min(ans,memo[ppl][vote-1]+(ld)a[pos]/(ppl+1));
if(vote!=0&&ppl!=0&&b[pos]<=1000){
ans=min(ans,memo[ppl-1][vote-1]+(ld)b[pos]/ppl);
}
memo[ppl][vote]=ans;
}
}
}
ld ans=INF;
for(int i=0;i<=n;++i)ans=min(ans,memo[i][k]);
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... |