Submission #540407

#TimeUsernameProblemLanguageResultExecution timeMemory
540407omohamadoooExhibition (JOI19_ho_t2)C++14
100 / 100
171 ms5636 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl '\n'
#define pii pair<ll,ll>
#define F first
#define S second
#define double long double
#define all(x) (x).begin(),(x).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree<ll , null_type , less_equal<ll> ,rb_tree_tag ,tree_order_statistics_node_update >ordered_set;

const int MOD = 1e9 + 7;
const int  N=1e6 + 7 ;
const ll INF= 1e18+10;

struct trp{ll F,S,T;};

ll po1(ll x,ll y)
{
    ll ans = 1;
    while(y){
        if( y & 1 ) ans *=x;
        y /= 2;
        x *=x;
        x %= MOD;
        ans %= MOD;
    }
    return ans;
}

ll b[N];
ll n , m;
pii a[N];

bool cmp(pii a,pii b)
{
    if(a.S !=b.S) return a.S < b.S;
    return a.F < b.F;
}

void solve()
{
    cin >> n >> m;
    for(ll i= 1; i <= n ; i ++ ) cin>> a[i].F >> a[i].S;
    for(ll i= 1;i <= m ; i ++ ) cin >> b[i];
    sort(a + 1 , a + n + 1, cmp);
    sort(b + 1 , b + m + 1);
    ll l = n , r = m;
    while(r > 0 && l > 0){
        if(a[l].F <= b[r]){
            r --;
            l --;
        }
        else l --;
    }

    cout << m - r << endl;
}

int main(){
    //ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen(".in" , "r" , stdin);freopen(".out" , "w" , stdout);
	int t = 1;
    //cin >> t;
	while(t--) {solve() ; }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...