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>
#define int long long
#define INF 1000000000000000
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
#define mid(l, u) ((l+u)/2)
#define x(p) p.first
#define y(p) p.second
#define MOD 998244353
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin>>n>>m;
pair<int, int> p[n];
for(int i = 0;i<n;i++) cin>>p[i].second>>p[i].first;
sort(p, p+n);
vector<int> fs;
for(int i = 0;i<m;i++){
int temp;
cin>>temp;
fs.push_back(temp);
}
sort(fs.begin(), fs.end());
int maxi = 0;
int ans = 0;
for(int i = n-1;i>=0;i--){
//cout<<p[i].first<<" "<<p[i].second<<" "<<Ca
auto it = lower_bound(fs.begin(), fs.end(), p[i].second);
int cant = it - fs.begin();
int can = m - cant;
int curr = min(maxi+1, can);
maxi = max(maxi, curr);
ans = max(ans, curr);
}
cout<<ans<<"\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... |