結果

問題 No.116 門松列(1)
ユーザー Theta
提出日時 2022-10-21 19:45:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 484 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-07-01 05:00:49
合計ジャッジ時間 2,132 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import Sequence


def is_kadomatsu(height_seq: Sequence[int]) -> bool:
    if len(set(height_seq)) != 3:
        return False

    if max(height_seq) == height_seq[1] or min(height_seq) == height_seq[1]:
        return True
    return False


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

    ctr = 0
    for idx in range(N-2):
        if is_kadomatsu(A[idx:idx+3]):
            ctr += 1

    print(ctr)


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