Advertisement
wrench786

Lifeguards

Jan 30th, 2022
1,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int arr[101][3];
  5.  
  6. void solve(){
  7.     int n;
  8.     scanf("%d",&n);
  9.  
  10.     for(int i=1;i<=n;i++){
  11.         scanf("%d %d",&arr[i][1],&arr[i][2]);
  12.     }
  13.  
  14.     int ans=0;
  15.     for(int i=1;i<=n;i++){
  16.         set<int>se;
  17.         for(int j=1;j<=n;j++){
  18.             if(i==j) continue;
  19.  
  20.             for(int x = arr[j][1]+1 ;x<= arr[j][2] ;x++){
  21.                 se.insert(x);
  22.             }
  23.  
  24.         }
  25.         ans = max(ans, (int)se.size());
  26.     }
  27.     printf("%d\n",ans);
  28. }
  29.  
  30. int main()
  31. {
  32.     freopen("lifeguards.in", "r", stdin);
  33.     freopen("lifeguards.out", "w", stdout);
  34.     int tc=1;
  35.     //scanf("%d",&tc);
  36.  
  37.     while(tc--){
  38.         solve();
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement