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 <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> s1(N), e1(N), s2(N), e2(N);
for (int i=0; i<N; i++) cin >> s1[i] >> e1[i];
for (int i=0; i<N; i++) cin >> s2[i] >> e2[i];
int cnt = 0;
int impos = 0;
for (int i=0; i<N; i++) {
int s = max(s1[i], s2[i]);
int e = min(e1[i], e2[i]);
if (s < e) cnt ++;
if (s > e) impos = 1;
}
if (impos) cout << -1 << endl;
else cout << cnt << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |