Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n, t;
  10.    
  11.     cin >> n >> t;
  12.    
  13.     vector<int> left(n), right(n);
  14.    
  15.     for(int i = 0; i < n; i++)
  16.         cin >> left[i] >> right[i];
  17.     int ans = 0;
  18.     for(int k = 0; k < n; k++)
  19.     {
  20.            
  21.         for(int z = 0; z <= 1; z++)
  22.         {
  23.             int i = left[k] - z;
  24.             int count = 0;
  25.         for(int j = 0; j < n; j++)
  26.         {
  27.             if (left[j] < i && i+t-1 < right[j]) count--;
  28.             else if (i <= left[j] && i + t - 1 >=right[j]) count++;
  29.             //cout << i << ' ' << left[j] << ' ' << right[j] << ' ' << count << '\n';
  30.         }
  31.                 ans= max(ans, count);
  32.         }
  33.        
  34.    
  35.     }
  36.     cout << ans;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement