Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #define max(a,b) \
- ({ __typeof__ (a) _a = (a); \
- __typeof__ (b) _b = (b); \
- _a > _b ? _a : _b; })
- #define min(a,b) \
- ({ __typeof__ (a) _a = (a); \
- __typeof__ (b) _b = (b); \
- _a < _b ? _a : _b; })
- int main(){
- int n;
- scanf("%d",&n);
- long l_border, r_border;
- long x, y;
- scanf("%ld %ld",&l_border, &r_border);
- while(2 == scanf("%ld %ld", &x, &y)){
- //printf("x:%ld, y:%ld, l_border:%ld, r_border:%ld, x>r_border:%d, y < l_border:%d\n",x,y,l_border,r_border,x>r_border,y<l_border);
- if (x > r_border+1 || y < l_border-1){
- printf("%ld %ld\n",l_border,r_border);
- l_border = x;
- r_border = y;
- continue;
- }
- r_border = max(r_border,y);
- l_border = min(l_border,x);
- }
- printf("%ld %ld\n",l_border,r_border);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement