标签:
题目链接:http://www.codeforces.com/problemset/problem/580/A
题意:求最长连续非降子序列的长度。
C++代码:
#include <iostream> using namespace std; const int maxn = 100100; int n, a[maxn], tmp, ans; int main() { cin >> n; for (int i = 0; i < n; i ++) cin >> a[i]; tmp = ans = 1; for (int i = 1; i <= n; i++) if (a[i] >= a[i-1]) { tmp ++; if (tmp > ans) ans = tmp; } else tmp = 1; cout << ans; return 0; }
codeforces水题100道 第十四题 Codeforces Round #321 (Div. 2) A. Kefa and First Steps (brute force)
标签:
原文地址:http://www.cnblogs.com/moonlightpoet/p/5689173.html