답안 #957564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957564 2024-04-04T03:36:27 Z Pring Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
2500 ms 51268 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

// #define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;

const int MXN = 505;
int n, k;
pii p[MXN];

int suf[MXN][MXN];
double dp[MXN][MXN];

void GET_SUF() {
    vector<int> v;
    for (int i = n; i > 0; i--) {
        v.push_back(p[i].fs);
        sort(v.begin(), v.end());
        suf[i][0] = 0;
        FOR(j, 0, v.size()) suf[i][j + 1] = suf[i][j] + v[j];
    }
}

double calc(int g) {
    dp[0][0] = 0.0;
    FOR(j, 1, g + 1) dp[0][j] = 3.9e239;
    FOR(i, 1, k + 1) {
        dp[i][0] = dp[i - 1][0] + (double) p[i].fs / (g + 1);
        FOR(j, 1, g + 1) {
            dp[i][j] = min(dp[i - 1][j] + (double) p[i].fs / (g + 1), dp[i - 1][j - 1] + (double) p[i].sc / j);
        }
    }
    FOR(j, 0, g + 1) {
        FOR(i, 0, k + 1) cout << setw(8) << dp[i][j] << ' ';
        cout << endl;
    }
    cout << endl;
    double ans = 3.9e239;
    FOR(i, 0, k + 1) ans = min(ans, dp[i][g] + (double) suf[i + 1][k - i] / (g + 1));
    return ans;
}

void miku() {
    cin >> n >> k;
    FOR(i, 1, n + 1) {
        cin >> p[i].fs >> p[i].sc;
        if (p[i].sc == -1) p[i].sc = 2e9;
    }
    sort(p + 1, p + n + 1, [](pii a, pii b) -> bool {
        return a.sc < b.sc;
    });
    GET_SUF();
    double ans = 3.9e239;
    FOR(g, 0, k + 1) {
        double x = calc(g);
        debug(g, x);
        ans = min(ans, x);
    }
    cout << fixed << setprecision(10) << ans << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}

Compilation message

Main.cpp: In function 'void miku()':
Main.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
Main.cpp:70:9: note: in expansion of macro 'debug'
   70 |         debug(g, x);
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2521 ms 51268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -