답안 #734590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734590 2023-05-02T16:52:19 Z Josia Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
2500 ms 8240 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;

    array<array<double, 505>, 505> dp;
    for (int i=0; i<n; i++) {
        for (auto &a: dp) for (auto &b: a) b = 1e10;
        dp[0][0] = 0;
        for (int j=0; j<n; j++) {
            for (int k=0; k<=min(i, j); 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Incorrect 3 ms 2260 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Incorrect 3 ms 2260 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2527 ms 8240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2260 KB Output is correct
2 Correct 3 ms 2260 KB Output is correct
3 Incorrect 3 ms 2260 KB Output isn't correct
4 Halted 0 ms 0 KB -