結果

問題 No.116 門松列(1)
ユーザー トミー
提出日時 2024-04-12 23:55:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-10-02 23:51:59
合計ジャッジ時間 1,997 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

def dif(a,b,c):
    return (a!=b and b!=c and c!=a)

def main():
    n=int(input())
    l_list=list(map(int,input().split()))
    cnt=0
    for i in range(len(l_list)-2):
        a=l_list[i]
        b=l_list[i+1]
        c=l_list[i+2]
        cnt=cnt+1 if dif(a,b,c) and (b==max(a,b,c) or b==min(a,b,c)) else cnt
    print(cnt)
        
        


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