답안 #636882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636882 2022-08-30T11:07:56 Z danikoynov Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
2 ms 340 KB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int maxn = 510;
struct city
{
    int a, b, idx;
}c[maxn], ct[maxn];
int n, k, used[maxn];

bool cmpa(city c1, city c2)
{
    return c1.a < c2.a;
}
bool cmpb(city c1, city c2)
{
    if (c1.b != -1 && c2.b != -1)
        return c1.b < c2.b;
    if (c1.b != -1)
        return true;
    if (c2.b != -1)
        return false;
    return c1.idx < c2.idx;
}
void solve()
{
    cin >> n >> k;
    int col = 0;
    for (int i = 1; i <= n; i ++)
    {
        cin >> c[i].a >> c[i].b;
        if (c[i].b != -1)
            col ++;
        c[i].idx = i;
        ct[i] = c[i];
    }

    sort(c + 1, c + n + 1, cmpa);
    sort(ct + 1, ct + n + 1, cmpb);

    double best = 1e18;
    for (int f = 0; f <= min(col, k); f ++)
    {
        double ans = 0.0, hp = 0;
        for (int i = 1; i <= n; i ++)
            used[i] = 0;
        for (int i = 1; i <= f; i ++)
        {
            ans = ans + (double)(ct[i].b) / (hp + 1.0);
            used[ct[i].idx] = 1;
            hp ++;
        }

        ///cout << f << " - " << ans << endl;
        int sum = 0;
        for (int i = 1; i <= n && sum < k - (int)f; i ++)
        {
            if (used[c[i].idx])
                continue;

            ans = ans + (double)(c[i].a) / (hp + 1.0);
            sum ++;
        }
        best = min(best, ans);
    }
    printf("%0.6f\n", best);
}

int main()
{
    solve();
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 220 KB Output is correct
11 Correct 1 ms 216 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 220 KB Output is correct
11 Correct 1 ms 216 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Incorrect 1 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -