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 <cstdio>
#include <vector>
#include <iostream>
using namespace std;
int main() {
int n;
while(cin >> n) {
vector<int> a, b, c, d;
a.resize(n);
b.resize(n);
c.resize(n);
d.resize(n);
for(int i=0; i<n; ++i) cin >> a[i] >> b[i];
for(int i=0; i<n; ++i) cin >> c[i] >> d[i];
vector<int> e, f;
e.resize(n);
f.resize(n);
for(int i=0; i<n; ++i) {
e[i] = max(a[i], c[i]);
f[i] = min(b[i], d[i]);
}
int ans = 0;
for(int i = 0; i < n; ++ i) {
if(e[i] > f[i]) {
ans = -1;
break;
}
else if(e[i] < f[i]) {
ans ++;
}
}
cout << ans << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |