-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVa 111.cpp
38 lines (35 loc) · 943 Bytes
/
UVa 111.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define endll "\n\n"
#define ll long long
#define pb push_back
using namespace std;
map<int, int> ans;
signed main() {
IO;
#ifdef DEBUG
freopen("p.in", "r", stdin);
freopen("p.out", "w", stdout);
#endif
int n, realMp, idk; cin>>n;
vector<int> buf(n);
for (auto i=0; i<n;i++){
cin>>realMp;
ans[i] = realMp-1;
}
while (cin>>idk) {
buf[ans[0]] = idk;
for (auto i=1; i<n;i++) {
cin>>idk;
buf[ans[i]] = idk;
}
vector<int> lis;
lis.pb(buf[0]);
for(int i = 0; i < buf.size(); i++)
for(int j = 0; j < i; j++) if(buf[j] < buf[i])
lis[i] = max(lis[i], lis[j] + 1);
cout<<*max_element(lis.begin(), lis.end())<<endl;
}
return EXIT_SUCCESS;
}