Submission #642711

#TimeUsernameProblemLanguageResultExecution timeMemory
642711zxcvbnmOlympiads (BOI19_olympiads)C++14
44 / 100
2087 ms131864 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...