样例过了 but UKE 本蒟蒻恳请大佬调教(在下抱拳)
查看原帖
样例过了 but UKE 本蒟蒻恳请大佬调教(在下抱拳)
1229717
LeavingAC楼主2024/8/19 20:13
#include <bits/stdc++.h>
using namespace std;
using ll=long long;//十年OJ一场空,不开long long见祖宗。(py党除外)

ll n,a[100010],num=1,ans=0;

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);//加速cin和cout    
    cin>>n;
    for (ll i=1;i<=n;i++)
    {
        cin >> a[i];
        if (i>=2)//
        {
            //判断是否递增
            if (a[i]>a[i-1]) 
            {
                num++;
            }//如果递增就将子段长度+1
            else 
            {
                ans=max(ans,num);
                num=1;
            }//如果非递增 就记录当前子段的长度 并更新ans 将子段长度归1
        }
    }
    ans=max(ans,num);//防止整个序列为最大上升子段
    cout<<ans;
    return 0;
}
2024/8/19 20:13
加载中...