-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathlis_brute.cpp
63 lines (46 loc) Β· 919 Bytes
/
lis_brute.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
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define lli long long int
using namespace std;
int lis(vector<int> arr) {
if(arr.empty()) return 0;
int len = arr.size(), answer = 1;
for(int i=0; i < len; i++) {
vector<int> next;
for(int j=i+1; j < len; j++) {
if(arr[j] > arr[i]) next.push_back(arr[j]);
}
answer = max(answer, 1 + lis(next));
}
return answer;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
vector<int> arr;
int n, num;
cin >> n;
for(int i=0;i<n;i++) {
cin >> num;
arr.pb(num);
}
// arr.pb(10);
// arr.pb(20);
// arr.pb(10);
// arr.pb(30);
// arr.pb(20);
// arr.pb(50);
// arr.pb(40);
// arr.pb(25);
// arr.pb(20);
// arr.pb(50);
// arr.pb(30);
// arr.pb(70);
// arr.pb(85);
// cout << lis(arr) << "\n";
}