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 fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define endl "\n"
#define sp " "
#define N 100005
#define LOGN 17
#define int long long
int v[N], s[N], c[N];
int n, m;
vector<pii> pic;
vector<int> fra;
int check(int x)
{
int i = 0, j = (m - x);
while (i < n && j < m)
{
int a = pic[i].nd, b = fra[j];
if (a <= b) i++, j++;
else i++;
}
//cout<<endl;
if (j == m) return 1;
return 0;
}
int32_t main()
{
//fileio();
fastio();
cin>>n>>m;
for (int i = 1; i <= n; i++)
cin>>s[i]>>v[i];
for (int i = 1; i <= m; i++)
cin>>c[i];
for (int i = 1; i <= n; i++) pic.pb({v[i], s[i]});
for (int j = 1; j <= m; j++) fra.pb(c[j]);
sort(pic.begin(), pic.end());
sort(fra.begin(), fra.end());
int bound = min(n, m);
int ans = 0;
for (int i = LOGN; i >= 0; i--)
{
int tmp = ans + (1<<i);
if (tmp <= bound && check(tmp)) ans = tmp;
}
cout<<ans<<endl;
cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |