結果

問題 No.1188 レベルX門松列
ユーザー tamatotamato
提出日時 2020-10-03 20:37:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 849 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 87,588 KB
実行使用メモリ 93,908 KB
最終ジャッジ日時 2023-09-25 07:12:32
合計ジャッジ時間 4,567 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
92,980 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 69 ms
71,616 KB
testcase_06 AC 94 ms
92,340 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 67 ms
71,484 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 66 ms
71,712 KB
testcase_21 AC 68 ms
71,400 KB
testcase_22 AC 68 ms
71,580 KB
testcase_23 AC 68 ms
71,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    inc = [0] * N
    dec = [0] * N
    for i in range(1, N):
        if A[i] > A[i-1]:
            inc[i] = inc[i-1] + 1
        else:
            inc[i] = 0
        if A[i] < A[i-1]:
            dec[i] = dec[i-1] + 1
        else:
            dec[i] = 0

    inc_r = [0] * N
    dec_r = [0] * N
    for i in range(N-2, -1, -1):
        if A[i] > A[i+1]:
            inc_r[i] = inc_r[i+1] + 1
        else:
            inc_r[i] = 0
        if A[i] < A[i+1]:
            dec_r[i] = dec_r[i+1] + 1
        else:
            dec_r[i] = 0

    ans = 0
    for i in range(N):
        ans = max(ans, min(inc[i], inc_r[i]), min(dec[i], dec_r[i]))
    print(ans)


if __name__ == '__main__':
    main()
0