#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> pii;
inline void solve()
{
int n, m;
cin >> n >> m;
vector<pii> v(n);
for (pii &i : v)
cin >> i.second >> i.first;
vector<int> f(m);
for (auto &i : f)
cin >> i;
sort(v.begin(), v.end()), sort(f.begin(), f.end());
reverse(v.begin(), v.end()), reverse(f.begin(), f.end());
// cout << '\n';
// for (auto i : v)
// cout << i.first << ' ' << i.second << '\n';
// for (int i : f)
// cout << i << ' ';
// cout << '\n';
int mx = 0;
vector<int> tmp;
for (pii i : v)
{
while (!tmp.empty() && f[tmp.back()] < i.second)
tmp.pop_back();
if ((tmp.empty() || tmp.back() < m) && i.second <= f[(tmp.empty() ? 0 : tmp.back() + 1)])
tmp.emplace_back(tmp.empty() ? 0 : tmp.back() + 1);
mx = max(mx, (int)tmp.size());
}
cout << min(mx, m) << '\n';
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |