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;
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";
}
# | 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... |