-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPOJ_2533_LIS.cpp
More file actions
53 lines (43 loc) · 955 Bytes
/
POJ_2533_LIS.cpp
File metadata and controls
53 lines (43 loc) · 955 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
using namespace std;
int solve(int *arr, int n){
int c = 0;
for(int i=1; i<n; i++){
if(arr[0] != arr[i]){
c = 1; break;
}
} if(c == 0){
return 1;
}
int lis[2][n+1];
memset(lis, 0, sizeof(lis));
lis[0][0] = INT_MIN;
// lis[2][0] = -1;
int ans = 0;
for(int cc=1; cc<n+1; cc++){
lis[0][cc] = arr[cc-1];
for(int c=0; c<cc; c++){
if(lis[0][c] < lis[0][cc]){
int ck = lis[1][cc];
lis[1][cc] = max(lis[1][cc], lis[1][c] + 1);
ans = max(ans, lis[1][cc]);
// if(ck != lis[1][cc] && ){
// lis[2][cc] = c;
// }
}
}
}
return ans;
}
int main(){
int n; cin >> n;
int arr[n];
for(int i=0; i<n; i++){
cin >> arr[i];
}
cout << solve(arr, n) << endl;
return 0;
}