# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
598916 | denniskim | Let's Win the Election (JOI22_ho_t3) | C++17 | 1 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[510];
pair<ll, ll> won[510];
ld ans = INF;
ll chk[510];
ld calc(void)
{
vector<ll> aa, bb;
ld ret = 0;
ll ppl = 1;
for(ll i = 1 ; i <= n ; i++)
{
if(chk[i] == 1)
aa.push_back({won[i].se});
else if(chk[i] == 2)
bb.push_back({won[i].fi});
}
sort(bb.begin(), bb.end());
for(auto &i : bb)
{
ret += (ld)i / (ld)ppl;
ppl++;
}
for(auto &i : aa)
ret += (ld)i / (ld)ppl;
return ret;
}
int main(void)
{
scanf("%lld", &n);
scanf("%lld", &k);
for(ll i = 1 ; i <= n ; i++)
{
scanf("%lld %lld", &a[i].fi.se, &a[i].fi.fi);
if(a[i].fi.fi == -1)
a[i].fi.fi = 10000000000000;
won[i] = a[i].fi;
a[i].se = i;
}
assert(k <= 5);
sort(a + 1, a + 1 + n);
for(ll i = 1 ; i <= k ; i++)
chk[a[i].se] = 2;
for(ll i = 0 ; i < k ; i++)
{
vector<ll> vec;
vector< pair< pair<ll, ll>, ll> > vec2;
ld minn = INF;
ll mini = INF, ww = 0;
ll ad = 0, sb = 0;
ans = min(ans, calc());
for(ll j = 1 ; j <= n ; j++)
{
if(chk[a[j].se] == 2)
vec.push_back(j);
else if(!chk[a[j].se])
{
if(mini > a[j].fi.se)
{
mini = a[j].fi.se;
ww = j;
}
}
}
for(auto &j : vec)
{
chk[a[j].se] = 0;
chk[a[j].se] = 1;
ld gappp = calc();
if(minn > gappp)
{
minn = gappp;
ad = a[j].se;
sb = a[j].se;
}
chk[a[j].se] = 2;
if(ww)
{
chk[a[j].se] = 0;
chk[a[ww].se] = 1;
gappp = calc();
if(minn > gappp)
{
minn = gappp;
ad = a[ww].se;
sb = a[j].se;
}
chk[a[j].se] = 2;
chk[a[ww].se] = 0;
}
}
chk[sb] = 0;
chk[ad] = 1;
}
ans = min(ans, calc());
printf("%.10Lf", ans);
return 0;
}
컴파일 시 표준 에러 (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... |