結果

問題 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
コンパイル時間 339 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,464 KB
最終ジャッジ日時 2024-04-23 09:17:34
合計ジャッジ時間 2,802 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
17,652 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 25 ms
10,624 KB
testcase_06 AC 84 ms
12,956 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 27 ms
10,624 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 28 ms
10,624 KB
testcase_21 AC 29 ms
10,624 KB
testcase_22 AC 28 ms
10,496 KB
testcase_23 AC 28 ms
10,496 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