Advertisement
tungSfer

tang giam

Jan 13th, 2022
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. void solution() {
  6.     int n;
  7.     cin>>n;
  8.     int ans = 1;
  9.     vector<double> a(n), b(n);
  10.     vector<int> dp(n,1);
  11.     for (int i = 0; i < n; i++)
  12.     {
  13.         cin>>a[i]>>b[i];
  14.     }
  15.  
  16.     for (int i = 1; i < n; i++)
  17.     {
  18.         for (int j = 0; j < i; j++)
  19.         {
  20.             if(a[i]>a[j] && b[i]<b[j]){
  21.                 dp[i] = max(dp[i],dp[j]+1);
  22.                 ans = max(ans, dp[i]);
  23.             }
  24.         }
  25.     }
  26.     cout<<ans<<endl;
  27.    
  28. }
  29.  
  30. int main() {
  31.     int t;
  32.     cin >> t;
  33.     while (t--) {
  34.         solution();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement