結果

問題 No.1188 レベルX門松列
ユーザー matsu7874
提出日時 2020-08-22 14:53:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,724 KB
最終ジャッジ日時 2024-10-15 09:11:27
合計ジャッジ時間 2,866 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n = int(input())
    if n < 3:
        print(0)
        return
    a = list(map(int, input().split()))
    l = [1]*n
    if a[0] == a[1]:
        run = [1]
        cur = 1
    else:
        run = []
        cur = 2
    for i in range(2, n):
        if a[i-2] < a[i-1] < a[i] or a[i-2] > a[i-1] > a[i]:
            cur += 1
        else:
            run.append(cur)
            cur = 1
    run.append(cur)
    max_run = 0
    for i, v in enumerate(run):
        if i+1 < len(run) and v + run[i+1] > max_run:
            max_run = v + run[i+1]
    print((max_run-1)//2)


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