codeforces水题100道 第十四题 Codeforces Round #321 (Div. 2) A. Kefa and First Steps (brute force)

时间:2021-08-19 08:28:26

题目链接:http://www.codeforces.com/problemset/problem/580/A
题意:求最长连续非降子序列的长度。
C++代码:

#include <iostream>
using namespace std;
const int maxn = ;
int n, a[maxn], tmp, ans;
int main()
{
cin >> n;
for (int i = ; i < n; i ++)
cin >> a[i];
tmp = ans = ;
for (int i = ; i <= n; i++)
if (a[i] >= a[i-])
{
tmp ++;
if (tmp > ans) ans = tmp;
}
else
tmp = ;
cout << ans;
return ;
}

C++