Submission #734441

# Submission time Handle Problem Language Result Execution time Memory
734441 2023-05-02T12:06:24 Z Josia Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
2500 ms 994576 KB
#include <bits/stdc++.h>

using namespace std;

#define int uint64_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;
    }

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

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



    vector<vector<vector<double>>> dp(n+1, vector<vector<double>>(n+1, vector<double>(n+1, 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++) {
                vector<double> options;
                options.push_back(dp[i][votes][colab]);
                if (votes > 0) options.push_back(dp[i][votes-1][colab] + ((double)a[i]/(colab+1)));
                if (votes > 0 && colab > 0 && b[i] != -1) options.push_back(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;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:48:52: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long unsigned int>, long unsigned int>::value_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |                 if (votes > 0 && colab > 0 && b[i] != -1) options.push_back(dp[i][votes-1][colab-1] + ((double)b[i]/colab));
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2622 ms 994568 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2622 ms 994568 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 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 -
# Verdict Execution time Memory Grader output
1 Execution timed out 2584 ms 994576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2622 ms 994568 KB Time limit exceeded
6 Halted 0 ms 0 KB -