Submission #364723

#TimeUsernameProblemLanguageResultExecution timeMemory
364723tushar_2658Exhibition (JOI19_ho_t2)C++14
0 / 100
1 ms364 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){
    return x.second < y.second;
  });
  sort(c + 1, c + m + 1); 
  int ptr = n, ans = 0; 
  for(int i = m; i > 0 && ptr > 0; --i){
    while(ptr > 0 && p[ptr].first > c[i]){
      --ptr;
    }
    if(ptr > 0 && p[ptr].first <= c[i]){
      ++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...