题解 | #Redraiment的走法#

Redraiment的走法

https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa

#include <vector>
#include <iostream>
using namespace std;

int main() {
   int n;
   int t;
   cin >> n;
   vector<int> l;
   for(int i=0;i<n;i++){
    cin >> t;
    l.push_back(t);
   }
   int a[200] ={0};
   int max = -1;

   for(int i=0;i<l.size();i++){
        for(int j=0;j<i;j++){
            if(l[i] > l[j]){
                if (a[i] < a[j] +1){
                    a[i] = a[j] + 1;
                }    
            }
        }    
        if(max < a[i]){
            max = a[i];
        }   
   }
   cout << max + 1 << endl;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-16 01:46
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务