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;
signed main () {
int n, m, k;
cin >> n >> m >> k;
vector <vector <int>> a(n, vector <int> (m));
vector <int> v, pos(m,0);
function <void(int,int)> f=[&](int last, int cnt) {
if(cnt == k) {
v.push_back(accumulate(pos.begin(), pos.end(), 0));
return;
}
vector <int> prev=pos;
for(int i = last; i < n; i ++) {
for(int j = 0; j < m; j ++) {
pos[j] = max(pos[j], a[i][j]);
}
f(i+1, cnt + 1);
pos = prev;
}
};
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) {
cin >> a[i][j];
}
}
f(0, 0);
sort(v.rbegin(), v.rend());
// for(auto i : v) cout << i << " ";
cout << v[k-1];
return 0;
}
# | 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... |