Submission #364726

#TimeUsernameProblemLanguageResultExecution timeMemory
364726tushar_2658Exhibition (JOI19_ho_t2)C++14
100 / 100
65 ms5740 KiB
#include "bits/stdc++.h"
using namespace std;

const int maxn = 200005;
using ll = long long;

pair<ll, ll> p[maxn];
ll c[maxn];

int main(int argc, char const *argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; ++i){
    cin >> p[i].first >> p[i].second;
  }
  for(int i = 1; i <= m; ++i){
    cin >> c[i];
  }
  sort(p + 1, p + n + 1, [&](pair<int, int> x, pair<int, int> y){
    if(x.second == y.second){
      return x.first < y.first;
    }else {
      return x.second < y.second;
    }
  });
  sort(c + 1, c + m + 1); 
  int ptr = n, ans = 0; 
  for(int i = m; i > 0; --i){
    while(ptr > 0 && p[ptr].first > c[i]){
      --ptr;
    }
    if(ptr > 0){
      ++ans;
      --ptr;
    }
  }
  cout << ans << '\n';

  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...