Submission #522800

# Submission time Handle Problem Language Result Execution time Memory
522800 2022-02-05T22:21:47 Z LucaDantas Olympiads (BOI19_olympiads) C++17
44 / 100
2000 ms 131664 KB
#include <bits/stdc++.h>
using namespace std;

constexpr int maxn = 510, maxk = 10;

int n, k, c;
int a[maxn][maxk];

vector<int> tot;

int get(vector<int> vt) {
	static int aq[maxk];
	memset(aq, 0, sizeof aq);
	for(int x : vt) {
		for(int j = 0; j < k; j++)
			aq[j] = max(aq[j], a[x][j]);
	}
	int ans = 0;
	for(int j = 0; j < k; j++)
		ans += aq[j];
	return ans;
}

void create(int id, vector<int> a) {
	if(id == k) return (void)(tot.push_back(get(a)));
	for(int j = a.back()+1; j < n; j++) {
		a.push_back(j);
		create(id+1, a);
		a.pop_back();
	}
}

int main() {
	scanf("%d %d %d", &n, &k, &c);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < k; j++)
			scanf("%d", &a[i][j]);
	for(int i = 0; i < n; i++)
		create(1, {i});
	sort(tot.begin(), tot.end(), greater<int>());
	printf("%d\n", tot[c-1]);
}

Compilation message

olympiads.cpp: In function 'int main()':
olympiads.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d %d %d", &n, &k, &c);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:37:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |    scanf("%d", &a[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 832 KB Output is correct
2 Correct 14 ms 908 KB Output is correct
3 Correct 11 ms 840 KB Output is correct
4 Correct 8 ms 968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 664 ms 16884 KB Output is correct
2 Correct 664 ms 16760 KB Output is correct
3 Correct 679 ms 16792 KB Output is correct
4 Correct 638 ms 16800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 131664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 832 KB Output is correct
2 Correct 14 ms 908 KB Output is correct
3 Correct 11 ms 840 KB Output is correct
4 Correct 8 ms 968 KB Output is correct
5 Correct 664 ms 16884 KB Output is correct
6 Correct 664 ms 16760 KB Output is correct
7 Correct 679 ms 16792 KB Output is correct
8 Correct 638 ms 16800 KB Output is correct
9 Execution timed out 2076 ms 131664 KB Time limit exceeded
10 Halted 0 ms 0 KB -