This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int Z = 500, B = 6, MX = B * 1200;
int N, K, C, s[Z][B], a[MX][B], p[MX], cur;
bitset<Z> b[MX];
priority_queue<array<int, 2>> q;
void process() {
int u = cur++, w[K] {};
for(int j = K; j--; ) {
if(a[u][j] < 0) {
for(int i = N; i--; ) if(!b[u][i] && (a[u][j] < 0 || s[i][j] > s[a[u][j]][j])) a[u][j] = i;
if(a[u][j] < 0) return;
b[u][a[u][j]] = 1;
}
for(int i = K; i--; ) w[i] = max(w[i], s[a[u][j]][i]);
}
q.push({accumulate(w, w + K, 0), u});
}
int main() {
cin >> N >> K >> C;
for(int i = 0; i < N; ++i) for(int j = 0; j < K; ++j) cin >> s[i][j];
fill(a[0], a[0] + K, -1);
process();
while(--C) {
int u = q.top()[1]; q.pop();
for(int j = K; --j >= p[u]; ) {
b[cur] = b[u];
p[cur] = j;
b[u][a[u][j]] = 0;
a[u][j] = -1;
copy(a[u], a[u] + K, a[cur]);
process();
}
}
cout << q.top()[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |