답안 #171939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171939 2019-12-30T16:38:12 Z Tc14 Olympiads (BOI19_olympiads) C++17
0 / 100
15 ms 504 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 * t < 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;
        }
        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());
             ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -