Submission #556210

# Submission time Handle Problem Language Result Execution time Memory
556210 2022-05-02T15:20:45 Z sidon Olympiads (BOI19_olympiads) C++17
100 / 100
31 ms 1016 KB
#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
1 Correct 3 ms 448 KB Output is correct
2 Correct 4 ms 436 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 564 KB Output is correct
2 Correct 4 ms 816 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Correct 2 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 724 KB Output is correct
2 Correct 11 ms 848 KB Output is correct
3 Correct 15 ms 852 KB Output is correct
4 Correct 16 ms 852 KB Output is correct
5 Correct 16 ms 968 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 448 KB Output is correct
2 Correct 4 ms 436 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 4 ms 816 KB Output is correct
7 Correct 3 ms 724 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 11 ms 724 KB Output is correct
10 Correct 11 ms 848 KB Output is correct
11 Correct 15 ms 852 KB Output is correct
12 Correct 16 ms 852 KB Output is correct
13 Correct 16 ms 968 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 7 ms 592 KB Output is correct
16 Correct 18 ms 924 KB Output is correct
17 Correct 31 ms 1016 KB Output is correct
18 Correct 12 ms 616 KB Output is correct
19 Correct 11 ms 852 KB Output is correct