제출 #335335

#제출 시각아이디문제언어결과실행 시간메모리
335335AQTExhibition (JOI19_ho_t2)C++14
100 / 100
221 ms4588 KiB
#include <bits/stdc++.h>

using namespace std;

int N, M;
pair<int, int> arr[100005];
int brr[100005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M;
	for(int i = 1; i<=N; i++){
		cin >> arr[i].first >> arr[i].second;
	}
	for(int i = 1; i<=M; i++){
		cin >> brr[i];
	}
	sort(arr+1, arr+1+N, [](pair<int, int> p, pair<int, int> q){
		if(p.second == q.second){
			return p.first < q.first;
		}
		return p.second < q.second;
	});
	sort(brr+1, brr+1+M);
	int ptr = N;
	int ans =0;
	for(int i = M; i; i--){
		while(ptr && arr[ptr].first > brr[i]){
			ptr--;
		}
		if(ptr){
			ptr--;
			ans++;
		}
	}
	cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...