Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int c[22],r[22],pos[22],val[22];
- // freopen("input.txt", "r", stdin);
- //freopen("in.txt","r",stdin);
- int main ()
- {
- int n;
- cin>>n;
- for(int i=0; i<n;i++)
- {
- cin>>c[i];
- pos[c[i]] = i;
- }
- while(cin>>r[0])
- {
- for(int i=1; i<n;i++)
- cin>>r[i];
- // memset(val,1,sizeof(val));
- for(int i=0; i<n;i++)
- val[i] = 1;
- for(int i=0; i<n;i++)
- {
- for(int j=0; j<i;j++)
- {
- if(pos[r[i]] > pos[r[j]])
- {
- if( (val[j] + 1 ) > val[i] )
- {
- val[i] = val[j] + 1;
- }
- }
- }
- }
- int max =0;
- for(int i= 0; i<n;i++)
- {
- if(max < val[i])
- max = val[i];
- }
- cout<<max<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement