Submission #365199

#TimeUsernameProblemLanguageResultExecution timeMemory
365199Lam_lai_cuoc_doiExhibition (JOI19_ho_t2)C++17
100 / 100
55 ms4588 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

const bool typetest = 0;
const int N = 1e5 + 5;
const ll Inf = 1e17;
int n, m, ans(0);
int c[N], dp[N], last[N];
struct picture
{
    int s, v;
    bool operator<(const picture &a) const
    {
        return v > a.v || (v == a.v && s > a.s);
    }
} a[N];

void Read()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> a[i].s >> a[i].v;
    for (int i = 1; i <= m; ++i)
        cin >> c[i];
    sort(a + 1, a + n + 1);
    sort(c + 1, c + m + 1, greater<int>());
}

void Solve()
{
    int ans(0), j(1);
    for (int i = 1; i <= m; ++i)
    {
        while (j <= n && a[j].s > c[i])
            ++j;
        if (j > n)
            break;
        ++j;
        ++ans;
    }
    cout << ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t(1);
    if (typetest)
        cin >> t;
    for (int _ = 1; _ <= t; ++_)
    {
        Read();
        Solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...