답안 #863780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
863780 2023-10-21T03:35:33 Z Trisanu_Das Olympiads (BOI19_olympiads) C++17
68 / 100
2000 ms 576 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, sMax;
vector<pair<int, vi>> C;
multiset<int> S;
 
bool 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();
            if (sMin == sMax) return true;
        }
    }
    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 false;
            if (f(t - 1, i + 1, sNew, mNew)) return true;
        }
    }
 
    return false;
}
 
int main() {
 
    ios_base::sync_with_stdio(false);
 
    int x, xMax;
    vi M;
 
    cin >> n >> k >> c;
    C = vector<pair<int, vi>>(n, {0, vi(k)});
    M = vi(k);
 
    for (int i = 0; i < n; i++) {
        xMax = 0;
        for (int j = 0; j < k; j++) {
            cin >> x;
            C[i].second[j] = x;
            xMax = max(xMax, x);
            M[j] = max(M[j], x);
        }
        C[i].first = xMax;
    }
 
    sort(C.begin(), C.end(), greater<pair<int, vi>>());
 
    sMin = 0;
 
    sMax = 0;
    for (int i = 0; i < k; i++) {
        sMax += M[i];
    }
 
    f(k, 0, 0, vi(k));
 
    cout << sMin << endl;
 
    return 0;
}

Compilation message

olympiads.cpp: In function 'bool f(int, int, int, vi)':
olympiads.cpp:24:22: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |         if (S.size() > c) {
      |             ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 26 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 30 ms 348 KB Output is correct
4 Correct 7 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 26 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 33 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 30 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 428 KB Output is correct
15 Execution timed out 2048 ms 348 KB Time limit exceeded
16 Halted 0 ms 0 KB -