Submission #688506

# Submission time Handle Problem Language Result Execution time Memory
688506 2023-01-27T14:53:55 Z stanislavpolyn Olympiads (BOI19_olympiads) C++17
44 / 100
2000 ms 131864 KB
#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;

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 > n) return;
    rec(p + 1);
    st.pb(p);
    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];
        }
    }

    rec();

    sort(all(scores));
    reverse(all(scores));

    cout << scores[c - 1] << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 984 KB Output is correct
2 Correct 10 ms 984 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 5 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 558 ms 16852 KB Output is correct
2 Correct 515 ms 16804 KB Output is correct
3 Correct 660 ms 16876 KB Output is correct
4 Correct 534 ms 16828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 131864 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 984 KB Output is correct
2 Correct 10 ms 984 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 5 ms 984 KB Output is correct
5 Correct 558 ms 16852 KB Output is correct
6 Correct 515 ms 16804 KB Output is correct
7 Correct 660 ms 16876 KB Output is correct
8 Correct 534 ms 16828 KB Output is correct
9 Execution timed out 2080 ms 131864 KB Time limit exceeded
10 Halted 0 ms 0 KB -