-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpat-1045.cpp
More file actions
35 lines (31 loc) · 759 Bytes
/
Copy pathpat-1045.cpp
File metadata and controls
35 lines (31 loc) · 759 Bytes
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
#include <stdio.h>
#include <vector>
using namespace std;
int color[10000] = {0};
int length[10000] = {0};
vector<int> s;
int M[200] = {0};
int main()
{
int order = 1;
int N; scanf("%d", &N);
int m; scanf("%d", &m);
for (int i = 0; i < m; i++)
{int c; scanf("%d", &c); M[c-1] = order++;}
int n; scanf("%d", &n);
for (int i = 0; i < n; i++)
{int c; scanf("%d", &c); if(M[c-1] != 0) s.push_back(c);}
for (int i = 0; i < s.size(); i++) {
color[i] = M[s[i]-1]; length[i] = 1;
for (int j = 0; j < i; j++)
if (color[j] <= color[i]
&& length[j] + 1 > length[i])
{
length[i] = length[j] + 1;
}
}
//for (int i = 0; i < s.size(); i++)
//printf("%d %d\n", color[i], length[i]);
printf("%d\n", length[s.size() - 1]);
return 0;
}