結果
問題 |
No.116 門松列(1)
|
ユーザー |
|
提出日時 | 2016-08-03 16:20:14 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 96 ms / 5,000 ms |
コード長 | 382 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-06-25 01:18:52 |
合計ジャッジ時間 | 3,373 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Syntax OK
ソースコード
class Calc0116 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @n = args.shift.first.to_i @as = args.shift.map(&:to_i) end def run (1..(@n - 2)).count { |i| as = @as[(i - 1)..(i + 1)] as.uniq.size == as.size && [0, 2].include?(as.index(as.sort[1])) } end end puts Calc0116.new(STDIN.readlines).run if __FILE__ == $0