Skip to content

Commit 32fef6c

Browse files
authored
Create [12]_3.cpp
1 parent d871d11 commit 32fef6c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Solutions/[12]_3.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int n, result;
6+
vector<int> data;
7+
int dp[1000];
8+
9+
int main() {
10+
cin >> n;
11+
for (int i = 0; i < n; i++) {
12+
int x;
13+
cin >> x;
14+
data.push_back(x);
15+
}
16+
for (int i = 0; i < n; i++) {
17+
dp[i] = 1;
18+
for (int j = 0; j < i; j++) {
19+
if (data[j] < data[i]) {
20+
dp[i] = max(dp[i], dp[j] + 1);
21+
}
22+
}
23+
result = max(result, dp[i]);
24+
}
25+
cout << result;
26+
}

0 commit comments

Comments
 (0)