#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int mat[505][7];
int n, k, c;
vector<int> ans;
void go(vector<int> idx) {
if ((int) idx.size() == k) {
vector<int> best(k, 0);
for(int i : idx) {
for(int j = 0; j < k; j++) {
best[j] = max(best[j], mat[i][j]);
}
}
ans.push_back(accumulate(best.begin(), best.end(), 0));
//for(int i : idx) {
//cout << i << " ";
//} cout << "\n";
return;
}
for(int i = idx.empty() ? 0 : idx.back()+1; i < n; i++) {
idx.push_back(i);
go(idx);
idx.pop_back();
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k >> c;
for(int i = 0; i < n; i++) {
for(int j = 0; j < k; j++) {
cin >> mat[i][j];
}
}
go(vector<int>());
sort(ans.rbegin(), ans.rend());
//for(int i : ans) {
//cout << i << " ";
//} cout << "\n";
cout << ans[c-1] << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
984 KB |
Output is correct |
2 |
Correct |
17 ms |
984 KB |
Output is correct |
3 |
Correct |
11 ms |
968 KB |
Output is correct |
4 |
Correct |
8 ms |
1008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
682 ms |
16836 KB |
Output is correct |
2 |
Correct |
694 ms |
16844 KB |
Output is correct |
3 |
Correct |
666 ms |
16828 KB |
Output is correct |
4 |
Correct |
636 ms |
16848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2087 ms |
131864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
984 KB |
Output is correct |
2 |
Correct |
17 ms |
984 KB |
Output is correct |
3 |
Correct |
11 ms |
968 KB |
Output is correct |
4 |
Correct |
8 ms |
1008 KB |
Output is correct |
5 |
Correct |
682 ms |
16836 KB |
Output is correct |
6 |
Correct |
694 ms |
16844 KB |
Output is correct |
7 |
Correct |
666 ms |
16828 KB |
Output is correct |
8 |
Correct |
636 ms |
16848 KB |
Output is correct |
9 |
Execution timed out |
2087 ms |
131864 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |