-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlis2.cpp
50 lines (39 loc) · 900 Bytes
/
lis2.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
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
vector<int> cache;
int N;
int solve(int start, vector<int>& lis) {
int cacheSize = 1;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < cacheSize;) {
if (lis[i] <= cache[j]) {
cache[j] = lis[i];
break;
}
else {
++j;
if (cacheSize == j) {
++cacheSize;
}
}
}
}
return cacheSize;
}
int main() {
int numTestCase;
cin >> numTestCase;
for (int i = 0; i < numTestCase; ++i) {
cin >> N;
cache.assign(500, 1000000);
vector<int> lis(N);
for (int j = 0; j < N; ++j) {
cin >> lis[j];
}
cout << solve(0, lis) << endl;
}
return 0;
}