Submission #1098835

# Submission time Handle Problem Language Result Execution time Memory
1098835 2024-10-10T07:57:24 Z serifefedartar Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 2e5 + 100;

int n, m;
vector<pair<int,int>> v1;
vector<int> v2;

bool check(int x) {
    vector<pair<int,int>> vv(v1.begin(), v1.end());
    reverse(vv.begin(), vv.end());
    vector<int> Q;
    for (int i = m - x; i < m; i++)
        Q.push_back(v2[i]);

    for (auto u : Q) {
        while (vv.size() && vv.back().f > u)
            vv.pop_back();
        if (vv.empty())
            return false;
        vv.pop_back();
    }
    return true;
}

int main() {
    fast;
    cin >> n >> m;

    v1 = vector<pair<int,int>>(n);
    v2 = vector<int>(m);
    for (int i = 0; i < n; i++)
        cin >> v1[i].f >> v1[i].s;
    for (int i = 0; i < m; i++)
        cin >> v2[i];

    sort(v1.begin(), v1.end(), [&](pair<int,int> A, pair<int,int> B) {
        return A.s < B.s;
    });
    sort(v2.begin(), v2.end());

    int L = 1, R = min(n, m);
    int ans = 0;
    while (R >= L) {
        int mid = L + (R - L) / 2;
        if (check(mid)) {
            ans = mid;
            L = mid + 1;
        } else
            R = mid - 1;
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -