제출 #825903

#제출 시각아이디문제언어결과실행 시간메모리
825903dijbkrExhibition (JOI19_ho_t2)C++14
100 / 100
49 ms5644 KiB
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll n,m;
pair<ll,ll>p[200005];
ll a[200005];

bool check(ll x) {
   ll pos=m-x+1;
   for (ll i=1; i<=n; i++) {
      if (p[i].second<=a[pos]) {
         pos++;
         if (pos==m+1) {
            return true;
         }
      }
   }
   return false;
}

ll bs() {
   ll ans=0;
   ll l=1;
   ll r=min(m,n);
   while (l<=r) {
      ll mid=(l+r)/2;
      if (check(mid)) {
         ans=mid;
         l=mid+1;
      } else {
         r=mid-1;
      }
   }
   return ans;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL); cout.tie(NULL);
   cin >> n >> m;
   for (ll i=1; i<=n; i++) {
      cin >> p[i].second >> p[i].first;
   }
   sort(p+1,p+n+1);
   for (ll i=1; i<=m; i++) {
      cin >> a[i];
   }
   sort(a+1,a+m+1);
   cout << bs();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...