#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()
vi sco;
vi cur;
vector<vi> peop;
void dfs(int ind, int used) {
if (used==cur.size()) {
sco.pb(accumulate(all(cur),0));
return;
}
if (ind==peop.size()) {
return;
}
dfs(ind+1,used);
vi t=cur;
for (int i=0; i<cur.size(); i++) {
cur[i]=max(cur[i],peop[ind][i]);
}
dfs(ind+1,used+1);
cur=t;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n,k,c;
cin >> n >> k >> c;
cur.resize(k,0);
peop.resize(n,vi(k,0));
for (int i=0; i<n; i++) {
for (int j=0; j<k; j++) {
cin >> peop[i][j];
}
}
dfs(0,0);
sort(all(sco),[](int a, int b){return a>b;});
cout << sco[c-1] << '\n';
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... |