题解 | #Redraiment的走法#
Redraiment的走法
https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa
动态规划 #include <stdio.h> #define max(a,b)(a>b)?a:b; int n; int getmax(int* arr) { int score[n]; int scoremax=1; for(int i=0;i<n;i++) { score[i]=1; for(int j=0;j<i;j++) if(arr[i]>arr[j]) score[i]=max(score[i],score[j]+1); scoremax=max(scoremax,score[i]); } return scoremax; } int main() { scanf("%d",&n); int arr[1001]; for(int i=0;i<n;i++) { scanf("%d",&arr[i]); } int max=getmax(arr); printf("%d",max); return 0; }