Miyago147852

UVa 111

Mar 3rd, 2022
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  3. #define endl "\n"
  4. #define endll "\n\n"
  5. #define ll long long
  6. #define pb push_back
  7.  
  8. using namespace std;
  9.  
  10. map<int, int> ans;
  11.  
  12. signed main() {
  13.     IO;
  14.     #ifdef DEBUG
  15.         freopen("p.in", "r", stdin);
  16.         freopen("p.out", "w", stdout);
  17.     #endif
  18.     int n, realMp, idk; cin>>n;
  19.     vector<int> buf(n);
  20.     for (auto i=0; i<n;i++){
  21.         cin>>realMp;
  22.         ans[i] = realMp-1;
  23.     }
  24.     while (cin>>idk) {
  25.         buf[ans[0]] = idk;
  26.         for (auto i=1; i<n;i++) {
  27.             cin>>idk;
  28.             buf[ans[i]] = idk;
  29.         }
  30.         vector<int> lis;
  31.         lis.pb(buf[0]);
  32.         for(int i = 0; i < buf.size(); i++)
  33.             for(int j = 0; j < i; j++) if(buf[j] < buf[i])
  34.                 lis[i] = max(lis[i], lis[j] + 1);
  35.         cout<<*max_element(lis.begin(), lis.end())<<endl;
  36.     }
  37.     return EXIT_SUCCESS;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment