結果

問題 No.116 門松列(1)
ユーザー mkanenobu
提出日時 2018-03-24 23:35:34
言語 Nim
(2.2.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 363 bytes
コンパイル時間 3,072 ms
コンパイル使用メモリ 66,204 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 05:35:44
合計ジャッジ時間 4,086 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils, strutils

var
    n = readLine(stdin).parseInt
    a:seq[int] = readLine(stdin).split.map(parseInt)
    ans = 0

for i in 2..<n:
    var
        left = a[i - 2]
        center = a[i - 1]
        right = a[i]
    if (center < left and center < right) or (center > left and center > right):
        if left != right:
            ans += 1

echo ans
0