結果

問題 No.406 鴨等間隔の法則
ユーザー mesh1nek0x0mesh1nek0x0
提出日時 2018-08-03 22:16:20
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 429 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 11,956 KB
実行使用メモリ 27,820 KB
最終ジャッジ日時 2023-10-19 21:25:31
合計ジャッジ時間 12,307 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
20,720 KB
testcase_01 WA -
testcase_02 AC 87 ms
16,112 KB
testcase_03 AC 86 ms
16,112 KB
testcase_04 AC 509 ms
26,472 KB
testcase_05 AC 227 ms
19,964 KB
testcase_06 AC 237 ms
20,356 KB
testcase_07 AC 241 ms
20,448 KB
testcase_08 AC 505 ms
26,376 KB
testcase_09 AC 561 ms
27,660 KB
testcase_10 AC 260 ms
20,720 KB
testcase_11 AC 444 ms
25,256 KB
testcase_12 AC 311 ms
21,688 KB
testcase_13 AC 288 ms
21,440 KB
testcase_14 WA -
testcase_15 AC 101 ms
16,372 KB
testcase_16 AC 113 ms
16,636 KB
testcase_17 AC 102 ms
16,372 KB
testcase_18 AC 104 ms
16,636 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 134 ms
17,164 KB
testcase_22 WA -
testcase_23 AC 322 ms
22,192 KB
testcase_24 WA -
testcase_25 AC 567 ms
27,756 KB
testcase_26 WA -
testcase_27 AC 343 ms
25,404 KB
testcase_28 AC 359 ms
27,764 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 546 ms
27,412 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