Submission #863778

# Submission time Handle Problem Language Result Execution time Memory
863778 2023-10-21T03:29:16 Z Trisanu_Das Olympiads (BOI19_olympiads) C++17
44 / 100
2000 ms 133524 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 13 ms 980 KB Output is correct
2 Correct 10 ms 980 KB Output is correct
3 Correct 10 ms 984 KB Output is correct
4 Correct 6 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 555 ms 17072 KB Output is correct
2 Correct 514 ms 16892 KB Output is correct
3 Correct 544 ms 17836 KB Output is correct
4 Correct 524 ms 18640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2073 ms 133524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 980 KB Output is correct
2 Correct 10 ms 980 KB Output is correct
3 Correct 10 ms 984 KB Output is correct
4 Correct 6 ms 984 KB Output is correct
5 Correct 555 ms 17072 KB Output is correct
6 Correct 514 ms 16892 KB Output is correct
7 Correct 544 ms 17836 KB Output is correct
8 Correct 524 ms 18640 KB Output is correct
9 Execution timed out 2073 ms 133524 KB Time limit exceeded
10 Halted 0 ms 0 KB -