結果

問題 No.135 とりあえず1次元の問題
ユーザー tshigtshig
提出日時 2016-08-03 16:49:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 220 ms / 5,000 ms
コード長 355 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 11,432 KB
実行使用メモリ 29,792 KB
最終ジャッジ日時 2023-09-02 00:27:53
合計ジャッジ時間 3,897 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
29,756 KB
testcase_01 AC 78 ms
15,384 KB
testcase_02 AC 78 ms
15,080 KB
testcase_03 AC 79 ms
15,284 KB
testcase_04 AC 78 ms
15,176 KB
testcase_05 AC 79 ms
15,304 KB
testcase_06 AC 78 ms
15,272 KB
testcase_07 AC 79 ms
15,176 KB
testcase_08 AC 79 ms
15,124 KB
testcase_09 AC 79 ms
15,084 KB
testcase_10 AC 78 ms
15,160 KB
testcase_11 AC 78 ms
15,264 KB
testcase_12 AC 78 ms
15,240 KB
testcase_13 AC 79 ms
15,204 KB
testcase_14 AC 85 ms
15,112 KB
testcase_15 AC 79 ms
15,280 KB
testcase_16 AC 80 ms
15,096 KB
testcase_17 AC 80 ms
15,392 KB
testcase_18 AC 78 ms
15,320 KB
testcase_19 AC 80 ms
15,236 KB
testcase_20 AC 79 ms
15,196 KB
testcase_21 AC 181 ms
27,280 KB
testcase_22 AC 217 ms
29,792 KB
evil01.txt AC 212 ms
29,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Calc0135
  def initialize(args)
    args = args.map { |l| l.chomp.split(/\s+/) }
    @n = args.shift.first.to_i
    @xs = args.shift.map(&:to_i)
  end

  def run
    xs = @xs.uniq
    if xs.size == 1
      0
    else
      xs.sort.each_cons(2).map { |x1, x2| x2 - x1 }.min
    end
  end
end

puts Calc0135.new(STDIN.readlines).run if __FILE__ == $0
0