結果

問題 No.406 鴨等間隔の法則
ユーザー harhogefooharhogefoo
提出日時 2016-10-14 07:46:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 23,612 KB
最終ジャッジ日時 2023-09-21 18:16:11
合計ジャッジ時間 5,442 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
18,256 KB
testcase_01 AC 78 ms
15,072 KB
testcase_02 AC 84 ms
15,128 KB
testcase_03 AC 79 ms
15,304 KB
testcase_04 AC 131 ms
22,468 KB
testcase_05 AC 99 ms
17,880 KB
testcase_06 AC 100 ms
18,132 KB
testcase_07 AC 101 ms
18,120 KB
testcase_08 AC 127 ms
22,440 KB
testcase_09 AC 144 ms
23,572 KB
testcase_10 AC 103 ms
18,272 KB
testcase_11 AC 121 ms
21,532 KB
testcase_12 AC 108 ms
19,304 KB
testcase_13 AC 105 ms
19,268 KB
testcase_14 AC 135 ms
21,980 KB
testcase_15 AC 81 ms
15,560 KB
testcase_16 AC 82 ms
15,288 KB
testcase_17 AC 84 ms
15,308 KB
testcase_18 AC 82 ms
15,340 KB
testcase_19 AC 87 ms
15,536 KB
testcase_20 AC 87 ms
15,780 KB
testcase_21 AC 84 ms
15,764 KB
testcase_22 AC 91 ms
16,720 KB
testcase_23 AC 111 ms
19,424 KB
testcase_24 AC 131 ms
21,168 KB
testcase_25 AC 141 ms
23,480 KB
testcase_26 AC 153 ms
23,536 KB
testcase_27 AC 129 ms
23,588 KB
testcase_28 AC 131 ms
23,472 KB
testcase_29 AC 155 ms
23,612 KB
testcase_30 AC 153 ms
23,508 KB
testcase_31 AC 138 ms
23,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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