結果

問題 No.116 門松列(1)
ユーザー 小指が強い人
提出日時 2015-11-11 22:37:46
言語 Ruby
(3.4.1)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 284 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-06-25 01:11:52
合計ジャッジ時間 2,899 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map(&:to_i)
count = 0
(n - 2).times do |i|
    if a[i] <= a[i + 1] && a[i + 1] <= a[i + 2]
        next
    end
    if a[i] >= a[i + 1] && a[i + 1] >= a[i + 2]
        next
    end
    if a[i] == a[i + 2]
       next 
    end
    count += 1
end
puts count
0