Submission #949521

# Submission time Handle Problem Language Result Execution time Memory
949521 2024-03-19T10:16:04 Z LucaIlie Olympiads (BOI19_olympiads) C++17
13 / 100
1772 ms 596 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500;
const int MAX_K = 6;

struct team {
    int total;
    int score[MAX_K];

    void init() {
        total = 0;
        for ( int i = 0; i < MAX_K; i++ )
            score[i] = 0;
    }

    bool operator < ( const team &t ) const {
        return total < t.total;
    }

    team operator + ( const team &t ) const {
        team ans;

        ans.total = 0;
        for ( int i = 0; i < MAX_K; i++ ) {
            ans.score[i] = max( score[i], t.score[i] );
            ans.total += ans.score[i];
        }

        return ans;
    }
};

team students[MAX_N + 1], dp[MAX_N + 1][MAX_K + 1];

int m, cnt;
void bckt( int c, int s, int p, int n, team crt ) {
    if ( cnt >= m )
        return;

    if ( c > n - p )
        return;

    for ( int g = 0; g <= c; g++ )
        dp[p][g] = crt;
    for ( int i = p + 1; i <= n; i++ ) {
        dp[i][0] = dp[i - 1][0];
        for ( int g = 1; g <= c; g++ )
            dp[i][g] = max( dp[i - 1][g], dp[i - 1][g - 1] + students[i] );
    }

    if ( dp[n][c].total < s )
        return;

    if ( c == 0 ) {
        if ( crt.total >= s )
            cnt++;
        return;
    }

    for ( int i = p + 1; i <= n; i++ )
        bckt( c - 1, s, i, n, crt + students[i] );
}

int main() {
    int n, k;

    cin >> n >> k >> m;
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 0; j < k; j++ ) {
            cin >> students[i].score[j];
            students[i].total += students[i].score[j];
        }
    }

    int st = 0, dr = 6e6 + 1;
    while ( dr - st > 1 ) {
        int mij = (st + dr) / 2;

        cnt = 0;
        team crt;
        crt.init();
        bckt( k, mij, 0, n, crt );

        if ( cnt < m )
            dr = mij;
        else
            st = mij;
    }

    cout << st;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 375 ms 596 KB Output is correct
2 Correct 246 ms 524 KB Output is correct
3 Correct 133 ms 348 KB Output is correct
4 Correct 18 ms 540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 156 ms 344 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 685 ms 516 KB Output is correct
4 Incorrect 1772 ms 516 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 375 ms 596 KB Output is correct
2 Correct 246 ms 524 KB Output is correct
3 Correct 133 ms 348 KB Output is correct
4 Correct 18 ms 540 KB Output is correct
5 Incorrect 48 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -