Codeforces 580A Kefa and first Steps

Source: Internet
Author: User

A. 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≤ in) He makes ai -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 the subsegment of the sequence are its continuous fragment. A subsegment of numbers is called non-decreasing if all numbers on it follow in the non-decreasing order.

Help Kefa cope with this task!

Input

The first line contains integer n (1≤ n ≤105).

The second line contains n integers a1, a2, ..., C15>an (1≤ ai ≤109).

Output

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

Sample Test (s) 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 are the numbers from the third to the fifth one.

In the second Test the maximum non-decreasing subsegment are the numbers from the first to the third one.

1#include <cstdio>2#include <cstring>3#include <algorithm>4 using namespacestd;5 intMain ()6 {7     inta[100005];8     intN;9scanf"%d",&n);Ten      for(intI=0; i<n;i++) Onescanf"%d",&a[i]); A     intans=0, maxn=1; -      for(intI=1; i<n;i++) -         if(a[i]>=a[i-1]) maxn++; the         ElseAns=max (Maxn,ans), maxn=1; -ans=Max (Maxn,ans); -printf"%d\n", ans); -     return 0; +}

Codeforces 580A Kefa and first Steps

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.