daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdio>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. struct point {
  8.     int x, y, t;
  9.  
  10.     point () {}
  11.  
  12.     point (int Y, int X, int T) : y ( Y), x (X), t (T) {}
  13.  
  14.     friend bool operator < (const point &a, const point &b) {
  15.         if (a.y != b.y) return a.y < b.y;
  16.         if (a.x != b.x) return a.x < b.x;
  17.         return a.t < b.t;
  18.     }
  19. };
  20. point d[200002];
  21.  
  22. int main(){
  23.     int i, n, y, xa, xb, t = 0, best = 0;
  24.     scanf("%d",&n);
  25.     for( i = 0; i < n; i++){
  26.         scanf("%d%d%d",&y, &xa, &xb);
  27.         d [ i * 2 ] = point (y, xa, 0);
  28.         d [ i * 2 + 1 ] = point(y, xb, 1);
  29.     }
  30.     n = n * 2;
  31.     sort(d, d + n);
  32.     for( i = 0; i < n; i++){
  33.         if ( d [ i ].t == 0) t++; else t--;
  34.         if(t > best) best = t;
  35.     }
  36.     if (best == 0) best++;
  37.     printf("%d\n",best);
  38.     system("pause");
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top