Submission #171946

# Submission time Handle Problem Language Result Execution time Memory
171946 2019-12-30T16:44:22 Z Tc14 Olympiads (BOI19_olympiads) C++17
0 / 100
2000 ms 632 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define Inf INT32_MAX
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

int n, k, c, sMin;
vector<pair<int, vi>> C;
set<int> S;

void f(int t, int j, int s, vi m) {

    int x, sNew;
    vi mNew;

    if (t == 0) {
        S.insert(s);
        if (S.size() > c) S.erase(S.begin());
        sMin = *S.begin();
    }
    else {
        for (int i = j + 1; i < n; i++) {
            if (s + C[i].first * k < sMin) return;
            sNew = 0;
            mNew = vi(6);
            for (int l = 0; l < k; l++) {
                x = max(m[l], C[i].second[l]);
                sNew += x;
                mNew[l] = x; 
            }
            f(t - 1, i, sNew, mNew);
        }
    }
}

int main() {

    ios_base::sync_with_stdio(false);

    int s, sMax;

    cin >> n >> k >> c;
    C = vector<pair<int, vi>>(n, {0, vi(k)});

    for (int i = 0; i < n; i++) {
        sMax = 0;
        for (int j = 0; j < k; j++) {
            cin >> s;
            C[i].second[j] = s;
            sMax = max(sMax, s);
        }
        C[i].first = sMax;
    }

    sort(C.begin(), C.end(), greater<pair<int, vi>>());

    sMin = 0;
    f(k, 0, 0, vi(k));

    cout << *S.begin() << endl;

    return 0;
}

Compilation message

olympiads.cpp: In function 'void f(int, int, int, vi)':
olympiads.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (S.size() > c) S.erase(S.begin());
             ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 474 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2044 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -