Submission #874173

#TimeUsernameProblemLanguageResultExecution timeMemory
874173vjudge1Olympiads (BOI19_olympiads)C++17
44 / 100
2045 ms132960 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; int matr[500][6]; #define ONLINE_JUDGE void solve() { int n, k, c; cin >> n >> k >> c; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { cin >> matr[i][j]; } } vector <int> vec; auto calc = [&]() -> int { vector <int> po(k); for(int &i : vec) { for(int j = 0; j < k; j++) { po[j] = max(po[j], matr[i][j]); } } return accumulate(po.begin(), po.end(), 0); }; vector <int> anss; function <void(int)> f = [&](int idx) -> void { if(int(vec.size()) == k) { anss.emplace_back(calc()); return; } if(idx == n) { return; } vec.emplace_back(idx); f(idx +1); vec.pop_back(); f(idx +1); }; f(0); sort(anss.begin(), anss.end(), greater <> ()); cout << anss[c -1]; return; } signed main() { #ifndef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...