//STRIKER!
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
#define int int64_t
#define pb push_back
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
void sol() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> a(n);
vector<int> sizm(m);
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
sort(all(a));
for (int i = 0; i < m; i++) {
cin >> sizm[i];
}
sort(all(sizm));
multiset<int> st;
vector<int> ans;
int j = 0;
for (int i = 0; i < m; i++) {
while (j < n and a[j].first <= sizm[i]) {
st.insert(a[j].second);
j++;
}
if (!st.empty()) {
ans.pb(*st.begin());
st.erase(st.begin());
}
}
int bst = (sz(ans) >= 1 ? 1 : 0);
int cur = 1;
for (int i = 1; i < sz(ans); i++) {
if (ans[i] >= ans[i - 1]) {
cur++;
}
else {
bst = max(bst, cur);
cur = 1;
}
}
bst = max(bst, cur);
cout << bst;
}
int32_t main() {
speed;
int t = 1;
//cin >> t;
while (t--) {
sol();
}
return 0;
}
//freopen("name", "r", stdin);
//freopen("name", "w", stdout);
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |