結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2022-11-03 19:54:51 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 82 ms / 5,000 ms |
コード長 | 365 bytes |
コンパイル時間 | 114 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-07-18 03:19:48 |
合計ジャッジ時間 | 2,776 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Main.rb:8: warning: assigned but unused variable - arr Syntax OK
ソースコード
n = gets.to_ia = gets.split.map(&:to_i)cnt = 0n.times do |i|next if i == 0 || i == n-1arr = [a[i-1], a[i], a[i+1]]if a[i-1] != a[i] && a[i] != a[i+1] && a[i+1] != a[i-1]c, d = [a[i-1], a[i], a[i+1]].minmaxunless (c == a[i-1] && d == a[i+1]) || (c == a[i+1] && d == a[i-1])cnt += 1endendendputs cnt