結果

問題 No.1188 レベルX門松列
ユーザー matsu7874matsu7874
提出日時 2020-08-22 14:53:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 19,800 KB
最終ジャッジ日時 2023-08-05 12:07:59
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,004 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 17 ms
7,736 KB
testcase_06 AC 69 ms
10,308 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 16 ms
7,752 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 16 ms
7,756 KB
testcase_21 AC 16 ms
7,864 KB
testcase_22 AC 16 ms
7,764 KB
testcase_23 AC 16 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

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