제출 #1349124

#제출 시각아이디문제언어결과실행 시간메모리
1349124sorb852Exhibition (JOI19_ho_t2)C++17
0 / 100
1 ms344 KiB
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);

  // freopen("other/input.txt", "r", stdin);

  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> painting(N, {0, 0}); // value - size
  vector<int> frames(M, 0);
  for (int i = 0; i < N; i++) {
    cin >> painting[i].second >> painting[i].first;
  }
  for (int j = 0; j < M; j++) {
    cin >> frames[j];
  }

  sort(painting.begin(), painting.end());
  sort(frames.begin(), frames.end());

  int ans = 0;
  int pP = 0, fP = 0;
  while (pP < N && fP < M) {
    if (painting[pP].second <= frames[fP]) {
      pP++;
      fP++;
      ans++;
      continue;
    } else {
      if (fP == M - 1) {
        pP++;
        continue;
      }
      fP++;
    }
  }
  cout << ans;
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...