This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool debug = false;
int mod = 1e9+7;
signed main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vector<pair<int, int>> pics(n);
	vector<int> frames(m);
	for (int i = 0; i < n; ++i){
		cin >> pics[i].second >> pics[i].first;
	}
	for (int i = 0; i < m; ++i){
		cin >> frames[i];
	}
	sort(frames.begin(), frames.end());
	sort(pics.begin(), pics.end());
	int lo = 0, hi = min(n, m)+1, mid = (lo + hi)/2, count, temp;
	bool found = false;
	while (lo < hi - 1){
		if(debug)cout << mid << '\n';
		count = 0;
		temp = 0;
		found = false;
		for (int i = 0; i < n; ++i){
			if (pics[i].first >= temp && pics[i].second <= frames[m-mid+count]){
				temp = pics[i].first;
				count++;
			}
			if (count == mid){
				found = true;
				lo = mid;
				mid = (lo + hi)/2;
				break;
			}
		}
		if (!found){
			hi = mid;
			mid = (lo + hi)/2;
		}
	}
	cout << lo;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |