# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598796 | denniskim | Let's Win the Election (JOI22_ho_t3) | C++17 | 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
ll n;
ll k;
pair< pair<ll, ll>, ll> a[1010], b[1010];
ld ans = INF;
ll chk[1010];
int main(void)
{
scanf("%lld", &n);
scanf("%lld", &k);
for(ll i = 1 ; i <= n ; i++)
{
scanf("%lld %lld", &a[i].fi.fi, &a[i].fi.se);
a[i].se = i;
b[i] = {{a[i].fi.se == -1 ? 10000000000 : a[i].fi.se, a[i].fi.fi}, i};
}
sort(a + 1, a + 1 + n);
sort(b + 1, b + 1 + n);
for(ll i = 0 ; i <= k ; i++)
{
ld sum = 0;
ll ppl = 1;
ll cou = 0;
for(ll j = 1 ; j <= i ; j++)
{
sum += (ld)b[j].fi.fi / (ld)ppl;
ppl++;
chk[b[j].se] = i + 1;
cou++;
}
for(ll j = 1 ; cou < k ; j++)
{
if(chk[a[j].se] == i + 1)
continue;
sum += (ld)a[j].fi.fi / (ld)ppl;
cou++;
}
ans = min(ans, sum);
}
printf("%.10Lf", ans);
return 0;
}
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... |