Submission #854521

#TimeUsernameProblemLanguageResultExecution timeMemory
854521tvladm2009Olympiads (BOI19_olympiads)C++17
44 / 100
2009 ms133688 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 500 + 7; const int K = 10; int score[N][K]; int n, k, c; vector<int> team, v; void rec(int cnt = 1) { if (cnt == k + 1) { vector<int> total(k + 1, 0); for (auto &i : team) { for (int j = 1; j <= k; j++) { total[j] = max(total[j], score[i][j]); } } int now = 0; for (int j = 1; j <= k; j++) { now += total[j]; } v.push_back(now); return; } int start = (team.empty() ? 1 : team.back() + 1); for (int i = start; i <= n; i++) { team.push_back(i); rec(cnt + 1); team.pop_back(); } } signed main() { #ifdef ONPC freopen ("input.txt", "r", stdin); #else ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif // ONPC cin >> n >> k >> c; for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { cin >> score[i][j]; } } rec(); sort(v.begin(), v.end()); reverse(v.begin(), v.end()); cout << v[c - 1] << "\n"; return 0; } /** dp[i][mxa][mxb] = ? **/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...