-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11722.cpp
More file actions
41 lines (37 loc) · 668 Bytes
/
Copy path11722.cpp
File metadata and controls
41 lines (37 loc) · 668 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
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int N, answer;
vector<int> arr, dp;
int dfs(int now)
{
if (dp[now] != 0)
return dp[now];
int re = 0;
for (int i = now + 1; i < N; i++)
{
if (arr[now] > arr[i])
{
re = max(re, dfs(i));
}
}
answer = max(answer, dp[now] = max(dp[now], re + 1));
return re + 1;
}
int main()
{
scanf("%d", &N);
arr.assign(N, 0);
dp.assign(N, 0);
for (int i = 0; i < N; i++)
{
scanf("%d", &arr[i]);
}
for (int i = 0; i < N; i++)
{
dfs(i);
}
printf("%d\n", answer);
return 0;
}