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;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void setIO()
{
    fast;
}
bool cmp1(vi&f,vi&s)
{
    return (f[1] > s[1]) || (f[1] == s[1] and f[0] > s[0]);
}
bool cmp2(int f,int s)
{
    return f >= s;
}
int main()
{
    setIO();
    int n,m;
    cin>>n>>m;
    vvi a(n,vi(2));
    for (int i = 0;i<n;i++)
        cin>>a[i][0]>>a[i][1];
    vi s(m);
    for (int i = 0;i<m;i++)cin>>s[i];
    
    //s[i + 1] >= s[i] and a[i + 1][1] >= a[i][1] and 
    //a[i][0] <= s[i]
    
    sort(a.begin(),a.end(),cmp1);
    sort(s.begin(),s.end(),cmp2);
    
    //hence s[i + 1] >= s[i] and a[pos + 1][1] >= a[pos][1]
    //hence we only need to ensure a[pos][0] <= s[i]
    
    int pos = 0;
    int ans = 0;
    for (int sz:s){
        while (pos < n and !(a[pos][0] <= sz))pos++;
        ans += pos++ < n;
    }
    cout<<ans<<"\n";
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |