結果

問題 No.116 門松列(1)
ユーザー HKDnet
提出日時 2015-01-12 00:57:34
言語 Ruby
(3.4.1)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 321 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-06-25 00:57:13
合計ジャッジ時間 3,173 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
Syntax OK

ソースコード

diff #

def is_kadomatsu? (a, b, c)
  if a == b || b == c || c == a
    return false
  end
  tmp = [a, b, c]
  return b == tmp.max || b == tmp.min
end
gets
arr = gets.chomp.split.map{|str| str.to_i}
count = 0
2.upto(arr.length - 1) {|idx|
  if is_kadomatsu?(arr[idx - 2], arr[idx - 1], arr[idx])
    count += 1
  end
}
puts count
0