Advertisement
Saleh127

UVA 10635 / LCS - LIS

Feb 15th, 2022
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. /***
  2.  created: 2022-02-16-02.07.44
  3. ***/
  4.  
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7. #define ll long long
  8. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  9. #define get_lost_idiot return 0
  10. #define nl '\n'
  11.  
  12. int main()
  13. {
  14.    ios_base::sync_with_stdio(0);
  15.    cin.tie(0);cout.tie(0);
  16.  
  17.  
  18.    test
  19.    {
  20.         ll n,m,i,j,l,p,q;
  21.         cin>>n>>p>>q;
  22.  
  23.         ll a[n*n + 2]={0};
  24.  
  25.         for(i=1;i<=p+1;i++)
  26.         {
  27.              cin>>m;
  28.              a[m]=i;
  29.         }
  30.  
  31.         multiset<ll>x;
  32.  
  33.         for(i=1;i<=q+1;i++)
  34.         {
  35.              cin>>m;
  36.  
  37.              x.insert(a[m]);
  38.  
  39.              auto k=x.upper_bound(a[m]);
  40.  
  41.              if(k!=x.end()) x.erase(k);
  42.         }
  43.  
  44.         cout<<"Case "<<cs<<": "<<x.size()<<nl;
  45.    }
  46.  
  47.  
  48.    get_lost_idiot;
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement