답안 #720975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720975 2023-04-10T01:09:31 Z Pring Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int, int> pii;

const int MXN = 15;
int n, m, fr[MXN], dp[MXN][MXN], lastC, ans;

struct P {
    int sz, val;
    P() {
        sz = 0;
        val = 0;
    }
    P(int _sz, int _val) {
        sz = _sz;
        val = _val;
    }
} pic[MXN];

// vector<int> ssq;

void SOLVE(int x) {
    vector<int> ssq;
    for (int i = 0; i < n; i++) {
        if (x & (1 << i)) ssq.push_back(i);
    }
    for (int i = 1; i < ssq.size(); i++) {
        if (pic[ssq[i - 1]].val > pic[ssq[i]].val) return;
    }
    int p = 0;
    for (auto &i : ssq) {
        while (p < m && pic[i].sz > fr[p]) p++;
        if (p == m) return;
        p++;
    }
    ans = max(ans, (int) ssq.size());
}

// void getDP(int id) {
//     cout << "id: " << id << endl;
//     while (pic[id].sz > fr[lastC]) lastC++;
//     cout << "lastC: " << lastC << endl;
//     vector<int> avail;
//     for (int i = 0; i < id; i++) if (pic[i].val <= pic[id].val) avail.push_back(i);
//     cout << "avail: ";
//     for (auto &i : avail) cout << i << ' ';
//     cout << endl;
//     for (int i = lastC; i < m; i++) {
//         dp[id][i] = 1;
//         for (auto &j : avail) {
//             dp[id][i] = max(dp[id][i], dp[j][i - 1] + 1);
//         }
//     }
//     ans = max(ans, dp[id][m - 1]);
// }

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> pic[i].sz >> pic[i].val;
    for (int i = 0; i < m; i++) cin >> fr[i];
    sort(pic, pic + n, [](P &a, P &b) {
        return (a.sz == b.sz ? a.val < b.val : a.sz < b.sz);
    });
    sort(fr, fr + m);
    fr[m] = LLONG_MAX;
    // for (int i = 0; i < n; i++) {
    //     getDP(i);
    // }
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < m; j++) {
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    // cout << ans << endl;

    // DFS(0, -1);

    for (int i = 0; i < (1 << n); i++) {
        SOLVE(i);
    }
    cout << ans << endl;
    return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'void SOLVE(long long int)':
joi2019_ho_t2.cpp:29:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 1; i < ssq.size(); i++) {
      |                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -