This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
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> ff;
for (int i = 0; i < n; i++)
{
int t = lower_bound(f.begin(), f.end(), p[i].second) - f.begin();
if (t == m)
continue;
ff.push_back(lower_bound(f.begin(), f.end(), p[i].second) - f.begin());
}
int ans = 0;
for (int i = 0; i < ff.size(); i++)
{
vector<int> lis;
for (int j = i; j < ff.size(); j++)
{
auto pos = upper_bound(lis.begin(), lis.end(), ff[j]);
if (pos == lis.end())
lis.push_back(ff[j]);
else
*pos = ff[j];
}
ans = max(ans, min(m - ff[i], (int)lis.size()));
}
cout << ans << '\n';
return 0;
}
// * * ***** * * * *
// * * * ** * * *
// ***** ***** * * * * *
// * * * * ** * *
// * * ***** * * ***
// ***** ***** * * * ***** * * ***** *****
// * * * * * * * ** * * * *
// * * * ***** * * * * * * *****
// * * * * * * * * ** * *
// **** ***** * ***** ***** * * * *
Compilation message (stderr)
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < ff.size(); i++)
~~^~~~~~~~~~~
joi2019_ho_t2.cpp:34:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = i; j < ff.size(); j++)
~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |