結果

問題 No.116 門松列(1)
ユーザー fine
提出日時 2016-03-07 01:21:19
言語 Ruby
(3.4.1)
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 285 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-06-25 01:16:21
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def kadomatsu a
    if a.uniq.size == 3 && (a[1] == a.max || a[1] == a.min)
        return true
    else
        return false
    end
end

ans = 0
n = gets.to_i
s = gets.split.map(&:to_i)
(n - 2).times{|i|
    if kadomatsu([s[i],s[i + 1],s[i + 2]])
        ans += 1
    end
    }
p ans
0