結果

問題 No.406 鴨等間隔の法則
ユーザー mesh1nek0x0mesh1nek0x0
提出日時 2018-08-03 22:17:05
言語 Ruby
(3.2.2)
結果
AC  
実行時間 621 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 26,844 KB
最終ジャッジ日時 2023-09-21 18:53:04
合計ジャッジ時間 11,985 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 263 ms
19,628 KB
testcase_01 AC 82 ms
15,056 KB
testcase_02 AC 83 ms
15,140 KB
testcase_03 AC 83 ms
15,216 KB
testcase_04 AC 527 ms
25,420 KB
testcase_05 AC 229 ms
18,896 KB
testcase_06 AC 238 ms
19,384 KB
testcase_07 AC 242 ms
19,312 KB
testcase_08 AC 514 ms
25,352 KB
testcase_09 AC 576 ms
26,720 KB
testcase_10 AC 263 ms
19,664 KB
testcase_11 AC 449 ms
24,076 KB
testcase_12 AC 312 ms
20,728 KB
testcase_13 AC 293 ms
20,512 KB
testcase_14 AC 501 ms
24,552 KB
testcase_15 AC 92 ms
15,420 KB
testcase_16 AC 106 ms
15,808 KB
testcase_17 AC 93 ms
15,580 KB
testcase_18 AC 97 ms
15,860 KB
testcase_19 AC 115 ms
15,808 KB
testcase_20 AC 132 ms
16,124 KB
testcase_21 AC 129 ms
16,204 KB
testcase_22 AC 179 ms
17,460 KB
testcase_23 AC 326 ms
21,112 KB
testcase_24 AC 458 ms
23,700 KB
testcase_25 AC 583 ms
26,792 KB
testcase_26 AC 621 ms
26,820 KB
testcase_27 AC 352 ms
24,616 KB
testcase_28 AC 368 ms
26,724 KB
testcase_29 AC 621 ms
26,844 KB
testcase_30 AC 609 ms
26,796 KB
testcase_31 AC 553 ms
26,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/bin/ruby
N = gets.chomp.to_i
kamos = gets.chomp.split(' ')
kamos_sorted = kamos.sort {|ele1, ele2| ele1.to_i <=> ele2.to_i }

if kamos.length != kamos_sorted.uniq.length
  puts 'NO'
else
  diff = kamos_sorted[1].to_i - kamos_sorted[0].to_i
  result = 'YES'
  for i in 1...kamos_sorted.length - 1 do
    if diff != (kamos_sorted[i + 1].to_i - kamos_sorted[i].to_i)
      result = 'NO'
      break
    end
  end
  puts result
end
0