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>
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 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... |