cf 580 A

A. Kefa and First Steps
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequenceai. 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

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

The second line contains n integers a1,  a2,  ...,  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 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 <iostream>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
const int maxn=100000+10;
const int inf=(1<<30);

int arr[maxn];
int d[maxn];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",arr+i);
        for(int i=1;i<=n;i++)
        {
            if(arr[i]>=arr[i-1])
                d[i]=d[i-1]+1;
            else
                d[i]=1;
        }
        sort(d,d+n+1);
        printf("%d\n",d[n]);
    }
    return 0;
}


Cmd line: com.ddu.astrology Build fingerprint: 'UMIDIGI/G100_Pro/G100_Pro:15/AP3A.240905.015.A2/1753929606:user/release-keys' ABI: 'arm64' Build type: optimized Debug Store: 1,0,85528573:: suspend all histogram: Sum: 19.513ms 99% C.I. 0.007ms-15.743ms Avg: 1.300ms Max: 16.752ms DALVIK THREADS (41): "main" prio=5 tid=1 Native | group="main" sCount=1 ucsCount=0 flags=1 obj=0x71f899d8 self=0xb4000073368847b0 | sysTid=26886 nice=-10 cgrp=top-app sched=0/0 handle=0x752ee25d20 | state=S schedstat=( 1463771336 633009323 2711 ) utm=89 stm=57 core=1 HZ=100 | stack=0x7fd55b9000-0x7fd55bb000 stackSize=8188KB | held mutexes= native: #00 pc 00086c2c /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28) (BuildId: cbe22ca05e685f937423c07537887fb8) native: #01 pc 0022a220 /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks+136) (BuildId: 629e0ffca501d809c29dbbeef2f512d3) native: #02 pc 007505f0 /apex/com.android.art/lib64/libart.so (art::JNI<false>::CallObjectMethodV+1216) (BuildId: 629e0ffca501d809c29dbbeef2f512d3) native: #03 pc 000d72c8 /system/lib64/libandroid_runtime.so (_JNIEnv::CallObjectMethod+120) (BuildId: 446475c21ccba32dedd924c1fc6be3cf) native: #04 pc 0015b270 /system/lib64/libandroid_runtime.so (android::NativeDisplayEventReceiver::dispatchVsync+64) (BuildId: 446475c21ccba32dedd924c1fc6be3cf) native: #05 pc 000de534 /system/lib64/libgui.so (android::DisplayEventDispatcher::handleEvent+580) (BuildId: 8f73ca0bad2e5f16091c1287a6f1294e) native: #06 pc 00013598 /system/lib64/libutils.so (android::Looper::pollOnce+1528) (BuildId: 9a2d718d33b2e2507f00741c21ca05c4) native: #07 pc 0018e0bc /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce+44) (BuildId: 446475c21ccba32dedd924c1fc6be3cf) at android.os.MessageQueue.nativePollOnce(Native method) at android.os.MessageQueue.next(MessageQueue.java:346) at android.os.Looper.loopOnce(Looper.java:189) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8758) at java.lang.reflect.Method.invoke(Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:962) DumpLatencyMs: 85.9148 "ReferenceQueueDaemon" daemon prio=5 tid=5 Waiting | group="system" sCount=1 ucsCount=0 flags=1 obj=0x140004f8 self=0xb40000733688b6f0 | sysTid=26891 nice=4 cgrp=top-app sched=0/0 handle=0x7232346730 | state=S schedstat=( 7912770 1146924 9 ) utm=0 stm=0 core=5 HZ=100 | stack=0x7232243000-0x7232245000 stackSize=1037KB | held mutexes= at java.lang.Object.wait(Native method) - waiting on <0x0b73e308> (a java.lang.Class<java.lang.ref.ReferenceQueue>) at java.lang.Object.wait(Object.java:405) at java.lang.Object.wait(Object.java:543) at java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:251) - locked <0x0b73e308> (a java.lang.Class<java.lang.ref.ReferenceQueue>) at java.lang.Daemons$Daemon.run(Daemons.java:131) at java.lang.Thread.run(Thread.java:1012) DumpLatencyMs: 143.96 "FinalizerWatchdogDaemon" daemon prio=5 tid=6 Sleeping | group="system" sCount=1 ucsCount=0 flags=1 obj=0x14000618 self=0xb400007336886380 | sysTid=26893 nice=4 cgrp=top-app sched=0/0 handle=0x7230126730 | state=S schedstat=( 1233927 5179845 12 ) utm=0 stm=0 core=7 HZ=100 | stack=0x7230023000-0x7230025000 stackSize=1037KB | held mutexes= at java.lang.Thread.sleep(Native method) - sleeping on <0x0fb44aa1> (a java.lang.Object) at java.lang.Thread.sleep(Thread.java:450) - locked <0x0fb44aa1> (a java.lang.Object) at java.lang.Thread.sleep(Thread.java:355) at java.lang.Daemons$FinalizerWatchdogDaemon.sleepForNanos(Daemons.java:517) at java.lang.Daemons$FinalizerWatchdogDaemon.waitForProgress(Daemons.java:580) at java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:448) at java.lang.Daemons$Daemon.run(Daemons.java:131) at java.lang.Thread.run(Thread.java:1012) DumpLatencyMs: 148.609 "FinalizerDaemon" daemon prio=5 tid=8 Waiting | group="system" sCount=1 ucsCount=0 flags=1 obj=0x14000588 self=0xb40000733688d2c0 | sysTid=26892 nice=4 cgrp=top-app sched=0/0 handle=0x7232236730 | state=S schedstat=( 2246770 1108615 10 ) utm=0 stm=0 core=7 HZ=100 | stack=0x7232133000-0x7232135000 stackSize=1037KB | held mutexes= at java.lang.Object.wait(Native method) - waiting on <0x080704c6> (a java.lang.Object) at java.lang.Object.wait(Object.java:405) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:207) - locked <0x080704c6> (a java.lang.Object) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:228) at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:331) at java.lang.Daemons$Daemon.run(Daemons.java:131) at java.lang.Thread.run(Thread.java:1012) DumpLatencyMs: 155.683 "GmsDynamite" prio=5 tid=19 Waiting | group="dynamiteLoader" sCount=1 ucsCount=0 flags=1 obj=0x14055998 self=0xb4000073368c30f0 | sysTid=26905 nice=19 cgrp=top-app sched=0/0 handle=0x71cec3a730 | state=S schedstat=( 359462 524308 1 ) utm=0 stm=0 core=4 HZ=100 | stack=0x71ceb37000-0x71ceb39000 stackSize=1037KB | held mutexes= at java.lang.Object.wait(Native method) - waiting on <0x05958c87> (a com.google.android.gms.dynamite.zza) at java.lang.Object.wait(Object.java:405) at java.lang.Object.wait(Object.java:543) at com.google.android.gms.dynamite.zza.run(unavailable:6) - locked <0x05958c87> (a com.google.android.gms.dynamite.zza) DumpLatencyMs: 173.528 "Measurement Worker" prio=5 tid=34 TimedWaiting | group="main" sCount=1 ucsCount=0 flags=1 obj=0x140faa58 self=0xb4000073368e7900 | sysTid=26925 nice=10 cgrp=top-app sched=0/0 handle=0x71c01e6730 | state=S schedstat=( 258300527 766020993 1179 ) utm=20 stm=4 core=7 HZ=100 | stack=0x71c00e3000-0x71c00e5000 stackSize=1037KB | held mutexes= at java.lang.Object.wait(Native method) - waiting on <0x08e827b4> (a java.lang.Object) at java.lang.Object.wait(Object.java:405) at m7.px.run(:com.google.android.gms.dynamite_measurementdynamite@252834035@25.28.34 (260400-0):67) - locked <0x08e827b4> (a java.lang.Object) DumpLatencyMs: 187.593
最新发布
08-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值