Submission #390883

#TimeUsernameProblemLanguageResultExecution timeMemory
390883vishesh312Exhibition (JOI19_ho_t2)C++17
100 / 100
78 ms4496 KiB
#include "bits/stdc++.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)x.size()

using ll = long long;
const int mod = 1e9+7;

void solve(int tc) {
    int n, m;
    cin >> n >> m;
    priority_queue<pair<int, int>> pq;
    while (n--) {
        int s, v;
        cin >> s >> v;
        pq.push({v, s});
    }
    vector<int> c(m);
    for (auto &x : c) cin >> x;
    sort(rall(c));
    int ans = 0;
    for (int x : c) {
        while (!pq.empty() and pq.top().second > x)
            pq.pop();
        if (pq.empty())
            break;
        pq.pop();
        ++ans;
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int tc = 1;
    //cin >> tc;
    for (int i = 1; i <= tc; ++i) solve(i);
    return 0;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...