题解 | #Redraiment的走法#

Redraiment的走法

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

//https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa?tpId=37&rp=1&ru=%2Fexam%2Foj%2Fta&qru=%2Fexam%2Foj%2Fta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26pageSize%3D50%26search%3D50%26tpId%3D37%26type%3D37&difficulty=&judgeStatus=&tags=&title=103&gioEnter=menu

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n = 0;
    int maxn = 1;

    while (cin >> n) {

        int dp[n];  //使用变量定义容器长度,一定要等变量的值确定后
        vector<int> height(n);

        for (int i = 0; i < n; i++)
            cin >> height[i];

        for (int i = 0; i < n; i++) {
            dp[i] = 1;
            for (int j = 0; j < i; j++)
                if (height[j] < height[i]){
                    dp[i] = max(dp[i], dp[j] + 1);
                    maxn = max(maxn, dp[i]);
                }

        }

        cout << maxn << endl;
    }

//    for(const int &num:dp)
//        cout << num;



}

全部评论

相关推荐

07-08 13:48
门头沟学院 C++
点赞 评论 收藏
分享
零OFFER战士:另一个版本查看图片
点赞 评论 收藏
分享
哈哈哈哈哈哈哈哈哈哈这个世界太美好了
凉风落木楚山秋:毕业出路老师不管,你盖个章他好交差就完事了,等你盖完毕业了就不关他事情了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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