Submission #688507

#TimeUsernameProblemLanguageResultExecution timeMemory
688507stanislavpolynOlympiads (BOI19_olympiads)C++17
31 / 100
472 ms16920 KiB
#include <bits/stdc++.h> #define fr(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, a, b) for (int i = (a); i >= (b); --i) #define fe(x, y) for (auto& x : y) #define fi first #define se second #define pb push_back #define mp make_pair #define mt make_tuple #define all(x) (x).begin(), (x).end() #define pw(x) (1LL << (x)) #define sz(x) (int)(x).size() using namespace std; mt19937_64 rng(228); #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define fbo find_by_order #define ook order_of_key template <typename T> bool umn(T& a, T b) { return a > b ? a = b, 1 : 0; } template <typename T> bool umx(T& a, T b) { return a < b ? a = b, 1 : 0; } using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using ve = vector<T>; int n, k, c; int a[505][7]; ve<int> st; int mx[7]; ve<int> scores; int sum[505]; ve<int> order; void rec(int p = 1) { if (sz(st) == k) { fr (i, 1, k) mx[i] = -1e9; fe (cur, st) { fr (i, 1, k) { umx(mx[i], a[cur][i]); } } int sum = 0; fr (i, 1, k) sum += mx[i]; scores.pb(sum); return; } if (p > min(n, 40)) return; rec(p + 1); st.pb(order[p - 1]); rec(p + 1); st.pop_back(); } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else ios::sync_with_stdio(0); cin.tie(0); #endif cin >> n >> k >> c; fr (i, 1, n) { fr (j, 1, k) { cin >> a[i][j]; sum[i] += a[i][j]; } order.pb(i); } sort(all(order), [](int i, int j) { return sum[i] > sum[j]; }); rec(); sort(all(scores)); reverse(all(scores)); cout << scores[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...