結果

問題 No.406 鴨等間隔の法則
ユーザー harhogefoo
提出日時 2016-10-14 07:46:15
言語 Ruby
(3.4.1)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-07-07 11:51:31
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i
x = gets.chomp.split(" ").map(&:to_i)

def check(p1, p2)
  if p1 == p2
    puts 'NO'
    exit
  end
end

x.sort!
check(x[0], x[1])

d = x[1] - x[0]
(x.length - 2).times do |p|
  check(x[p+2], x[p+1])
  dt = x[p+2] - x[p+1]
  if d != dt
    puts 'NO'
    exit
  end
end

puts 'YES'
0