답안 #734453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734453 2023-05-02T12:19:55 Z Josia Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
1070 ms 1010580 KB
#include <bits/stdc++.h>

using namespace std;

#define int int64_t

int n, k;


vector<int> a, b;


signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> n >> k;

    a.assign(n, 0);
    b.assign(n, 0);

    vector<pair<int, int>> blub(n);

    for (int i = 0; i<n; i++) {
        cin >> blub[i].second;
        cin >> blub[i].first;

        if (blub[i].first == -1) blub[i].first = 1e18;
    }

    sort(blub.begin(), blub.end());

    for (int i=0; i<n; i++) {
        a[i] = blub[i].second;
        b[i] = blub[i].first;
    }



    vector<array<array<double, 505>, 505>> dp(505, array<array<double, 505>, 505>());

    for (int i = 0; i<505; i++) {
        for (int j = 0; j<505; j++) {
            for (int k = 0; k<505; k++) {
                dp[i][j][k] = 1e18;
            }
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i<n; i++) {
        for (int votes = 0; votes<=n; votes++) {
            for (int colab = 0; colab<=n; colab++) {
                array<double, 3> options={1e18, 1e18, 1e18};
                options[0] = (dp[i][votes][colab]);
                if (votes > 0) options[1] = (dp[i][votes-1][colab] + ((double)a[i]/(colab+1)));
                if (votes > 0 && colab > 0 && b[i] != 1e18) options[2] = (dp[i][votes-1][colab-1] + ((double)b[i]/colab));
                dp[i+1][votes][colab] = *min_element(options.begin(), options.end());
                // cerr << dp[i+1][votes][colab] << "\n";
            }
        }
    }

    cout.precision(100);
    cout << *min_element(dp[n][k].begin(), dp[n][k].end()) << "\n";


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 516 ms 1010424 KB Output is correct
2 Correct 496 ms 1010432 KB Output is correct
3 Correct 493 ms 1010492 KB Output is correct
4 Correct 522 ms 1010384 KB Output is correct
5 Correct 867 ms 1010444 KB Output is correct
6 Correct 827 ms 1010328 KB Output is correct
7 Correct 825 ms 1010464 KB Output is correct
8 Correct 847 ms 1010376 KB Output is correct
9 Correct 844 ms 1010452 KB Output is correct
10 Correct 839 ms 1010448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 516 ms 1010424 KB Output is correct
2 Correct 496 ms 1010432 KB Output is correct
3 Correct 493 ms 1010492 KB Output is correct
4 Correct 522 ms 1010384 KB Output is correct
5 Correct 867 ms 1010444 KB Output is correct
6 Correct 827 ms 1010328 KB Output is correct
7 Correct 825 ms 1010464 KB Output is correct
8 Correct 847 ms 1010376 KB Output is correct
9 Correct 844 ms 1010452 KB Output is correct
10 Correct 839 ms 1010448 KB Output is correct
11 Correct 492 ms 1010420 KB Output is correct
12 Correct 998 ms 1010416 KB Output is correct
13 Correct 934 ms 1010508 KB Output is correct
14 Correct 891 ms 1010580 KB Output is correct
15 Correct 1008 ms 1010448 KB Output is correct
16 Correct 955 ms 1010444 KB Output is correct
17 Correct 862 ms 1010416 KB Output is correct
18 Correct 1006 ms 1010448 KB Output is correct
19 Correct 960 ms 1010444 KB Output is correct
20 Correct 918 ms 1010564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 507 ms 1010408 KB Output is correct
2 Correct 499 ms 1010372 KB Output is correct
3 Correct 555 ms 1010428 KB Output is correct
4 Correct 550 ms 1010372 KB Output is correct
5 Correct 666 ms 1010420 KB Output is correct
6 Correct 597 ms 1010352 KB Output is correct
7 Correct 569 ms 1010336 KB Output is correct
8 Correct 557 ms 1010428 KB Output is correct
9 Incorrect 516 ms 1010428 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 507 ms 1010408 KB Output is correct
2 Correct 499 ms 1010372 KB Output is correct
3 Correct 555 ms 1010428 KB Output is correct
4 Correct 550 ms 1010372 KB Output is correct
5 Correct 666 ms 1010420 KB Output is correct
6 Correct 597 ms 1010352 KB Output is correct
7 Correct 569 ms 1010336 KB Output is correct
8 Correct 557 ms 1010428 KB Output is correct
9 Incorrect 516 ms 1010428 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 507 ms 1010408 KB Output is correct
2 Correct 499 ms 1010372 KB Output is correct
3 Correct 555 ms 1010428 KB Output is correct
4 Correct 550 ms 1010372 KB Output is correct
5 Correct 666 ms 1010420 KB Output is correct
6 Correct 597 ms 1010352 KB Output is correct
7 Correct 569 ms 1010336 KB Output is correct
8 Correct 557 ms 1010428 KB Output is correct
9 Incorrect 516 ms 1010428 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1070 ms 1010520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 516 ms 1010424 KB Output is correct
2 Correct 496 ms 1010432 KB Output is correct
3 Correct 493 ms 1010492 KB Output is correct
4 Correct 522 ms 1010384 KB Output is correct
5 Correct 867 ms 1010444 KB Output is correct
6 Correct 827 ms 1010328 KB Output is correct
7 Correct 825 ms 1010464 KB Output is correct
8 Correct 847 ms 1010376 KB Output is correct
9 Correct 844 ms 1010452 KB Output is correct
10 Correct 839 ms 1010448 KB Output is correct
11 Correct 492 ms 1010420 KB Output is correct
12 Correct 998 ms 1010416 KB Output is correct
13 Correct 934 ms 1010508 KB Output is correct
14 Correct 891 ms 1010580 KB Output is correct
15 Correct 1008 ms 1010448 KB Output is correct
16 Correct 955 ms 1010444 KB Output is correct
17 Correct 862 ms 1010416 KB Output is correct
18 Correct 1006 ms 1010448 KB Output is correct
19 Correct 960 ms 1010444 KB Output is correct
20 Correct 918 ms 1010564 KB Output is correct
21 Correct 507 ms 1010408 KB Output is correct
22 Correct 499 ms 1010372 KB Output is correct
23 Correct 555 ms 1010428 KB Output is correct
24 Correct 550 ms 1010372 KB Output is correct
25 Correct 666 ms 1010420 KB Output is correct
26 Correct 597 ms 1010352 KB Output is correct
27 Correct 569 ms 1010336 KB Output is correct
28 Correct 557 ms 1010428 KB Output is correct
29 Incorrect 516 ms 1010428 KB Output isn't correct
30 Halted 0 ms 0 KB -