#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int matr[500][6];
#define ONLINE_JUDGE
void solve() {
int n, k, c;
cin >> n >> k >> c;
for(int i = 0; i < n; i++) {
for(int j = 0; j < k; j++) {
cin >> matr[i][j];
}
}
vector <int> vec;
auto calc = [&]() -> int {
vector <int> po(k);
for(int &i : vec) {
for(int j = 0; j < k; j++) {
po[j] = max(po[j], matr[i][j]);
}
}
return accumulate(po.begin(), po.end(), 0);
};
vector <int> anss;
function <void(int)> f = [&](int idx) -> void {
if(int(vec.size()) == k) {
anss.emplace_back(calc());
return;
}
if(idx == n) {
return;
}
vec.emplace_back(idx);
f(idx +1);
vec.pop_back();
f(idx +1);
};
f(0);
sort(anss.begin(), anss.end(), greater <> ());
cout << anss[c -1];
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
992 KB |
Output is correct |
2 |
Correct |
13 ms |
988 KB |
Output is correct |
3 |
Correct |
9 ms |
992 KB |
Output is correct |
4 |
Correct |
6 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
589 ms |
18560 KB |
Output is correct |
2 |
Correct |
602 ms |
18392 KB |
Output is correct |
3 |
Correct |
654 ms |
17700 KB |
Output is correct |
4 |
Correct |
609 ms |
18680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2045 ms |
132960 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
992 KB |
Output is correct |
2 |
Correct |
13 ms |
988 KB |
Output is correct |
3 |
Correct |
9 ms |
992 KB |
Output is correct |
4 |
Correct |
6 ms |
992 KB |
Output is correct |
5 |
Correct |
589 ms |
18560 KB |
Output is correct |
6 |
Correct |
602 ms |
18392 KB |
Output is correct |
7 |
Correct |
654 ms |
17700 KB |
Output is correct |
8 |
Correct |
609 ms |
18680 KB |
Output is correct |
9 |
Execution timed out |
2045 ms |
132960 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |