-
Notifications
You must be signed in to change notification settings - Fork 0
/
1045.cpp
33 lines (32 loc) · 831 Bytes
/
1045.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
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main() {
int colorNum, favorNum, stripNum, color;
cin >> colorNum >> favorNum;
map<int, int> mapFavor;
vector<int> LIS;
for(int favor = 1; favor <= favorNum; favor++) {
cin >> color;
mapFavor[color] = favor;
}
LIS.push_back(0);
cin >> stripNum;
for(int strip = 1; strip <= stripNum; strip++) {
cin >> color;
if(mapFavor.count(color) == 0) continue;
int seq = mapFavor[color];
if(seq >= LIS.back()) LIS.push_back(seq);
else {
* upper_bound(LIS.begin(), LIS.end(), seq) = seq;
}
// for(auto l: LIS) {
// cout << l << " ";
// }
// cout << endl;
}
cout << LIS.size() - 1;
return 0;
}