結果

問題 No.116 門松列(1)
ユーザー yamagh
提出日時 2015-08-23 20:34:04
言語 Ruby
(3.4.1)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 260 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-06-25 01:09:35
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:6: warning: assigned but unused variable - y
Syntax OK

ソースコード

diff #

N=gets.to_i
A=gets.split.map(&:to_i)

cnt=0
(N-2).times do |t|
  x,y,z=s=A.slice(t,3)
  next if s.uniq.size != 3 
  cnt+=1 if (x!=s.max && x!=s.min) || (z!=s.max && z!=s.min)
  #puts "t:#{t} x:#{x} y:#{y} z:#{z} max:#{s.max} min:#{s.min} cnt:#{cnt}"
end
p cnt
0