第一题 #include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; if(n <= 2){ cout<<0<<endl; return 0; } vector<int> nums(n, 0); for(int i = 0; i < n; i++) cin >> nums[i]; vector<int> dp(n, 1); for(int i = 1; i < n; i++){ if(nums[i] > nums[i-1]) dp[i] = dp[i-1] + 1; } // int res = 0; vector<int> res(n, 0); for(int i = 2; i < n; i++){ if(nums[i] < nums[i-1]){ res[i] = max(res[i], dp[i-1] + 1); if(res[i-1] != 0) res[i] = max(res[i], res[i-1] + 1); } } cout<<*max_element(res.begin(), res.end())<<endl; return 0; }
点赞 评论

相关推荐

09-18 20:41
阿里巴巴_后端
要个offer怎么这...:哈哈哈哈哈哈,我也拿了0x10000000个offer,秋招温啦啦啦,好开心
我的秋招日记
点赞 评论 收藏
分享
10-28 10:48
已编辑
门头沟学院 Java
孩子我想要offer:发笔试后还没笔试把我挂了,然后邮箱一直让我测评没测,后面不知道干嘛又给我捞起来下轮笔试,做完测评笔试又挂了😅
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务