#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<pair<int, int>> p(n);
vector<int> f(m);
for (int i = 0; i < n; i++)
cin >> p[i].second >> p[i].first;
for (int i = 0; i < m; i++)
cin >> f[i];
sort(p.begin(), p.end()), sort(f.begin(), f.end());
vector<int> lis;
vector<vector<pair<int, int>>> v;
for (int i = 0; i < n; i++)
{
int pos = lower_bound(f.begin(), f.end(), p[i].second) - f.begin();
if (pos == m)
continue;
int owo = upper_bound(lis.begin(), lis.end(), pos) - lis.begin();
if (owo == lis.size())
lis.push_back(pos), v.push_back({{i, pos}});
else
lis[owo] = pos, v[owo].push_back({i, pos});
}
/*for (auto vv : v)
{
for (auto i : vv)
cout << i.first << ' ' << i.second << " ";
cout << '\n';
}*/
if (lis.empty())
cout << "0\n";
else if (lis.size() == 1)
cout << "1\n";
else
{
int ans = 0;
for (auto p : *v.rbegin())
{
int mxm = prev(upper_bound(v[0].begin(), v[0].end(), make_pair(p.first, INF))) -> second;
ans = max(ans, min((int)lis.size(), m - mxm));
}
cout << ans << '\n';
}
return 0;
}
// * * ***** * * * *
// * * * ** * * *
// ***** ***** * * * * *
// * * * * ** * *
// * * ***** * * ***
// ***** ***** * * * ***** * * ***** *****
// * * * * * * * ** * * * *
// * * * ***** * * * * * * *****
// * * * * * * * * ** * *
// **** ***** * ***** ***** * * * *
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (owo == lis.size())
~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |