# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299898 | ly20 | Olympiads (BOI19_olympiads) | C++17 | 2083 ms | 17936 KiB |
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 MAXN = 510;
int n, k, c;
int val[MAXN][MAXN];
vector <int> at;
int mx[MAXN];
bool ok[MAXN];
void bk(int l, int a) {
if(n - a < l) return;
if(l == 0) {
for(int i = 0; i < k; i++) {
mx[i] = 0;
}
for(int i = 0; i < n; i++) {
if(ok[i]) {
//printf("%d ", i);
for(int j = 0; j < k; j++) mx[j] = max(mx[j], val[i][j]);
}
}
//printf("\n");
int resp = 0;
for(int i = 0; i < k; i++) {
resp += mx[i];
}
at.push_back(resp);
return;
}
if(a == n) return;
ok[a] = 1;
bk(l - 1, a + 1);
ok[a] = 0;
bk(l, a + 1);
}
bool cmp(int a, int b) {
return a > b;
}
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", &val[i][j]);
mx[j] = max(mx[j], val[i][j]);
}
}
bk(k, 0);
sort(at.begin(), at.end(), cmp);
printf("%d\n", at[c - 1]);
return 0;
}
Compilation message (stderr)
# | 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... |