Submission #9173

#TimeUsernameProblemLanguageResultExecution timeMemory
9173maniacN-orthotope (kriii2_N)C++98
4 / 4
0 ms1676 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...