結果

問題 No.116 門松列(1)
ユーザー siman
提出日時 2015-01-07 01:50:46
言語 Ruby
(3.4.1)
結果
AC  
実行時間 89 ms / 5,000 ms
コード長 300 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-06-25 00:56:47
合計ジャッジ時間 2,918 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

class A
  def initialize
    n = gets.chomp.to_i
    a = gets.chomp.split(' ').map(&:to_i)

    count = 0

    a.each_cons(3) do |list|
      next if list.uniq.size != list.size

      if list.max == list[1] || list.min == list[1]
        count += 1
      end
    end

    puts count
  end
end

A.new
0