# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824388 | Amylopectin | Let's Win the Election (JOI22_ho_t3) | C++14 | 2 ms | 340 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 <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int mxn = 2010;
struct we
{
double aa,bb;
int idx;
};
bool cmp1(const struct we &l,const struct we &r)
{
return l.aa < r.aa;
}
bool cmp2(const struct we &l,const struct we &r)
{
if(l.bb == -1)
{
return false;
}
if(r.bb == -1)
{
return true;
}
if(l.bb == r.bb)
{
return l.aa > r.aa;
}
return l.bb < r.bb;
}
struct we soa[mxn] = {},sob[mxn] = {};
int u[mxn] = {};
int main()
{
int i,j,n,m,cn,cm,fn,fm,cou;
double cva,cmi,f,p;
scanf("%d %d",&n,&m);
for(i=0; i<n; i++)
{
scanf("%lf %lf",&soa[i].aa,&soa[i].bb);
soa[i].idx = i;
sob[i] = {soa[i].aa,soa[i].bb,i};
}
sort(soa,soa+n,cmp1);
sort(sob,sob+n,cmp2);
for(i=0; i<n; i++)
{
if(i > 0 && sob[i-1].bb == -1)
{
break;
}
cva = 0;
for(j=0; j<i; j++)
{
u[sob[j].idx] = 1;
f = j + 1;
cva += sob[j].bb / f;
}
f = i+1;
cou = i;
for(j=0; j<n; j++)
{
if(u[soa[j].idx] == 0)
{
cou ++;
cva += soa[j].aa / f;
}
if(cou == m)
{
break;
}
}
if(i == 0)
{
cmi = cva;
}
else
{
cmi = min(cmi,cva);
}
}
printf("%lf\n",cmi);
}
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... |