题解 | #Redraiment的走法#

Redraiment的走法

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

#include <bits/stdc++.h>
using namespace std;
const int N = 210;
int main() {
    int n;
    cin >> n;
    int x;
    vector<int> nums;
    while(cin >> x){
        nums.push_back(x);
    }
    vector<int> dp(n, 1);
    for(int i = 1; i < nums.size(); ++i){
        for(int j = 0; j < i; ++j){
            if(nums[j] < nums[i]){
                dp[i] = max(dp[i], dp[j] + 1);
            }
        }
    }
    int count = 0;
    for(auto i : dp){
        count = max(count, i);
    }
    cout << count << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

2025-12-17 17:53
门头沟学院 Web前端
海梨花:我之前面试也是问我非技术问题,问过我怎么统计北京出租车数量,不借助任何网络或者其他平台的帮助,有足够多的人可以帮忙
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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