Submission #544840

#TimeUsernameProblemLanguageResultExecution timeMemory
544840skittles1412Olympiads (BOI19_olympiads)C++17
0 / 100
2 ms596 KiB
#include "bits/extc++.h" using namespace std; template <typename T> void dbgh(const T& t) { cerr << t << endl; } template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t << " | "; dbgh(u...); } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \ << ": "; \ dbgh(__VA_ARGS__) #else #define cerr \ if (false) \ cerr #define dbg(...) #endif #define endl "\n" #define long int64_t #define sz(x) int((x).size()) const int maxn = 10; vector<int> ans; int n, m, arr[maxn][6]; void dfs(int ind, int cur, array<int, 6> copt) { if (ind == m) { ans.push_back(accumulate(copt.begin(), copt.begin() + m, 0)); return; } for (int i = cur; i < n; i++) { auto tmp = copt; for (int j = 0; j < m; j++) { tmp[j] = max(tmp[j], arr[i][j]); } dfs(ind + 1, i + 1, tmp); } } void solve() { int k; cin >> n >> m >> k; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> arr[i][j]; } } dfs(0, 0, {}); k--; nth_element(begin(ans), ans.begin() + k, end(ans), greater<>()); cout << ans[k] << endl; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cin.exceptions(ios::failbit); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...