Kefa and First Steps-最大非递减子段的长度

Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) he makes a**i money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence a**i. Let us remind you that the subsegment of the sequence is its continuous fragment. A subsegment of numbers is called non-decreasing if all numbers in it follow in the non-decreasing order.

Help Kefa cope with this task!

Input
image20200607112620497.png

Output

Print a single integer — the length of the maximum non-decreasing subsegment of sequence a.

Examples

Input

6
2 2 1 3 4 1

Output

3

Input

3
2 2 9

Output

3

Note

In the first test the maximum non-decreasing subsegment is the numbers from the third to the fifth one.

In the second test the maximum non-decreasing subsegment is the numbers from the first to the third one.

简单题,直接输入的时候判断是不是比上一个小,如果是,重新计数;如果否,则计数。

#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int last,in,curLen =1,result=1;
    scanf("%d", &last);
    for (int i = 1; i < n; ++i) {
        scanf("%d", &in);
        if (in >= last){
            curLen++;
        } else{
            curLen = 1;
        }
        result = max(result,curLen);
        last = in;
    }
    printf("%d\n", result);
    return 0;
}