답안 #171961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171961 2019-12-30T17:09:05 Z Tc14 Olympiads (BOI19_olympiads) C++17
44 / 100
2000 ms 544 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;
multiset<int> S;

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

    int x, sNew, sNewMax;
    vi mNew;

    if (t == 0) {
        S.insert(s);
        if (S.size() > c) {
            S.erase(S.begin());
            sMin = *S.begin();
        }
    }
    else {
        for (int i = j; i < n; i++) {
            sNewMax = 0;
            sNew = 0;
            mNew = vi(k);
            for (int l = 0; l < k; l++) {
                x = max(m[l], C[i].second[l]);
                sNew += x;
                mNew[l] = x;
                sNewMax += max(x, C[i].first);
            }
            if (sNewMax < sMin) return;
            f(t - 1, i + 1, 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 << sMin << 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) {
             ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 28 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 45 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2062 ms 380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 28 ms 544 KB Output is correct
5 Correct 8 ms 376 KB Output is correct
6 Correct 45 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Execution timed out 2062 ms 380 KB Time limit exceeded
10 Halted 0 ms 0 KB -