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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int n, k, c;
//multiset<ll, greater<ll>> ss;
vector<ll> sth;
vector<vector<ll>> v;
void bf(int cnt, int c, vector<ll> cur){
if(cnt == k){
ll s = 0;
for(ll x: cur) s+=x;
//ss.insert(s);
//if(ss.size() > c+5) ss.erase(prev(ss.end()));
sth.pb(s);
return;
}
if(c == n) return;
bf(cnt, c+1, cur);
for(int i = 0; i < k; i++) cur[i] = max(cur[i], v[c][i]);
bf(cnt+1, c+1, cur);
if(c == n) return;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> c;
for(int i = 0; i < n; i++){
vector<ll> sth(k);
for(ll &x: sth) cin >> x;
v.pb(sth);
}
bf(0, 0, vector<ll>(k, 0));
c--;
//cout << *next(ss.begin(), c) << "\n";
sort(sth.rbegin(), sth.rend());
cout << sth[c] << "\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... |