Submission #734589

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

using namespace std;

#define int int64_t




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

    int n, K; cin >> n >> K;
    vector<array<int, 3>> inputA(n);
    vector<array<int, 3>> inputB(n);


    for (int i=0; i<n; i++) {
        int a, b; cin >> a >> b;

        if (b == -1) b = 1e18;

        inputA[i]={a, b, i};
        inputB[i]={b, a, i};
    }

    sort(inputA.begin(), inputA.end());
    sort(inputB.begin(), inputB.end());

    // vector<bool> topK(n, 0);
    // for (int i = 0; i<K; i++) {
    //     topK[inputA[i][2]] = 1;
    // }




    double res = 1e10;

    for (int i=0; i<n; i++) {
        vector<vector<double>> dp(n+1, vector<double>(n+1, 1e10));
        dp[0][0] = 0;
        for (int j=0; j<n; j++) {
            for (int k=0; k<n; k++) {
                cerr << dp[j][k] << " ";
                if (dp[j][k] == 1e10) continue;

                dp[j+1][k] = min(dp[j+1][k], dp[j][k]+(double)inputB[j][1]/(double)(i+1));
                dp[j+1][k+1] = min(dp[j+1][k+1], dp[j][k]+(double)inputB[j][0]/(double)(k+1));
            }
            cerr << "\n";
        }
        cerr << "\n";
        res = min(res, dp[n][i]);
    }



    // for (int colabs = 0; colabs<=K; colabs++) {
    //     for (int inTopK = 0; inTopK<=K; inTopK++) {
    //         double tmp = dp[n][inTopK][colabs];
    //         cerr << tmp << "\n";

    //         if (tmp == 1e10) continue;

    //         for  (int i = 0; i<K+inTopK; i++) {
    //             tmp += inputA[i][0];
    //         }

    //         res = min(res, tmp);
    //         cerr << "-" << tmp << "\n";
    //     }
    // }


    cout.precision(100);
    cout << res << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2547 ms 7748 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 320 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -