Submission #396464

#TimeUsernameProblemLanguageResultExecution timeMemory
396464KoDOlympiads (BOI19_olympiads)C++17
44 / 100
2090 ms120564 KiB
#include <bits/stdc++.h> template <class T> using Vec = std::vector<T>; template <class F> struct RecLambda: private F { explicit RecLambda(F&& f): F(std::forward<F>(f)) { } template <class... Args> decltype(auto) operator () (Args&&... args) const { return F::operator()(*this, std::forward<Args>(args)...); } }; using ll = long long; int main() { int N, K, C; std::cin >> N >> K >> C; Vec<Vec<int>> get(N, Vec<int>(K)); for (auto& v: get) { for (auto& x: v) { std::cin >> x; } } Vec<int> score; score.reserve(3838380); RecLambda([&](auto&& dfs, Vec<int> set) -> void { if ((int) set.size() == K) { int sum = 0; for (int i = 0; i < K; ++i) { int max = 0; for (const auto x: set) { max = std::max(max, get[x][i]); } sum += max; } score.push_back(sum); return; } for (int i = (set.empty() ? 0 : set.back() + 1); i < N; ++i) { set.push_back(i); dfs(set); set.pop_back(); } })(Vec<int>{}); std::sort(score.begin(), score.end(), std::greater<>()); std::cout << score[C - 1] << '\n'; 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...