답안 #171954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171954 2019-12-30T16:56:46 Z Tc14 Olympiads (BOI19_olympiads) C++17
13 / 100
2000 ms 508 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, X = 0;
vector<pair<int, vi>> C;
multiset<int> S;

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

    int x, sNew;
    vi mNew;

    if (t == 0) {
        X++;
        S.insert(s);
        if (S.size() > c) S.erase(S.begin());
        sMin = *S.begin();
    }
    else {
        for (int i = j; i < n; i++) {
            if (s + C[i].first * k < sMin) return;
            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;
            }
            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:25:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (S.size() > c) S.erase(S.begin());
             ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 6 ms 508 KB Output is correct
4 Correct 27 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 523 ms 476 KB Output is correct
2 Correct 587 ms 476 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2067 ms 504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 6 ms 508 KB Output is correct
4 Correct 27 ms 504 KB Output is correct
5 Correct 523 ms 476 KB Output is correct
6 Correct 587 ms 476 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -