#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> combinations;
vector<int> current;
void generate_combinations(int n, int k) {
//choose k of the first n
if (n<k-1) {
return;
}
if (k==0) {
combinations.push_back(current);
return;
}
if (n==0) {
return;
}
for (int i=0; i<n; i++) {
current.push_back(i);
generate_combinations(i,k-1);
current.pop_back();
}
}
signed main() {
//freopen("input.txt","r", stdin);
//freopen("output.txt","w",stdout);
int n,k,c;
cin >> n >> k >> c;
vector<vector<int>> cons;
for (int i=0; i<n; i++) {
vector<int> c1;
for (int j=0; j<k; j++) {
int x;
cin >> x;
c1.push_back(x);
}
cons.push_back(c1);
}
generate_combinations(n,k);
/*cout << combinations.size() << endl;
for (auto i:combinations) {
for (auto j:i) {
cout << j <<" ";
}
cout << endl;
}*/
vector<int> answers;
for (auto com:combinations) {
vector<int> maxes(k,0);
for (int i:com) {
for (int j=0; j<k; j++) {
maxes[j]=max(maxes[j],cons[i][j]);
}
}
answers.push_back(accumulate(maxes.begin(), maxes.end(), (int)0));
}
sort(answers.begin(), answers.end());
reverse(answers.begin(), answers.end());
/*for (auto i:answers) {
cout << i <<" ";
}
cout << endl;*/
cout << answers[c-1] << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
9224 KB |
Output is correct |
2 |
Correct |
16 ms |
9228 KB |
Output is correct |
3 |
Correct |
15 ms |
9140 KB |
Output is correct |
4 |
Correct |
12 ms |
9300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
147 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
163 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
9224 KB |
Output is correct |
2 |
Correct |
16 ms |
9228 KB |
Output is correct |
3 |
Correct |
15 ms |
9140 KB |
Output is correct |
4 |
Correct |
12 ms |
9300 KB |
Output is correct |
5 |
Runtime error |
147 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |