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<cassert>
#include<cstring>
#include<map>
#include<set>
#include<time.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<limits>
using namespace std;
long long gcd( long long b, long long s ){
return (s!=0) ? gcd( s, b%s ) : b;
}
int n,s[2][22],e[2][22],le[22],ri[22],re;
void solve(){
scanf("%d",&n);
for(int i = 0; i< n; i++){
scanf("%d %d",&s[0][i],&e[0][i]);
}
for(int i = 0; i< n; i++){
scanf("%d %d",&s[1][i],&e[1][i]);
}
for(int i = 0; i< n; i++){
le[i] = max( s[0][i],s[1][i]);
ri[i] = min( e[0][i],e[1][i]);
}
re = n;
for(int i = 0; i< n; i++){
if( le[i] < ri[i] )
continue;
else if( le[i] == ri[i] )
re--;
else{
re = -1;
break;
}
}
printf("%d\n",re);
}
int main(){
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |