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 <iostream>
#include <vector>
#include <utility>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<pair<int, int> > v1, v2;
	for (int i = 0; i < n; i++){
		int s, e;
		cin >> s >> e;
		v1.push_back(make_pair(s, e));
	}
	for (int i = 0; i < n; i++){
		int s, e;
		cin >> s >> e;
		v2.push_back(make_pair(s, e));
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		int si = v1[i].first, ei = v1[i].second,
			sj = v2[i].first, ej = v2[i].second;
		
		if (ei < sj || si > ej) {
			cout << -1 << endl;
			goto l;
		}
		else if (ei == sj || si == ej) {
			ans += 0;
		}
		else {
			ans++;
		}
	}
	cout << ans << endl;
	l:;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |