結果

問題 No.135 とりあえず1次元の問題
ユーザー mesh1nek0x0mesh1nek0x0
提出日時 2018-07-14 21:30:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 180 ms / 5,000 ms
コード長 251 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 28,544 KB
最終ジャッジ日時 2024-04-20 01:59:15
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
28,544 KB
testcase_01 AC 80 ms
12,160 KB
testcase_02 AC 77 ms
12,288 KB
testcase_03 AC 77 ms
12,288 KB
testcase_04 AC 81 ms
12,288 KB
testcase_05 AC 81 ms
12,032 KB
testcase_06 AC 78 ms
12,160 KB
testcase_07 AC 81 ms
12,160 KB
testcase_08 AC 77 ms
12,160 KB
testcase_09 AC 78 ms
12,032 KB
testcase_10 AC 78 ms
12,160 KB
testcase_11 AC 78 ms
12,288 KB
testcase_12 AC 77 ms
12,288 KB
testcase_13 AC 78 ms
12,160 KB
testcase_14 AC 79 ms
12,160 KB
testcase_15 AC 78 ms
12,032 KB
testcase_16 AC 80 ms
12,032 KB
testcase_17 AC 77 ms
12,288 KB
testcase_18 AC 80 ms
12,160 KB
testcase_19 AC 79 ms
12,160 KB
testcase_20 AC 77 ms
12,288 KB
testcase_21 AC 118 ms
19,328 KB
testcase_22 AC 179 ms
27,904 KB
evil01.txt AC 171 ms
28,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/bin/ruby
N = gets.chomp
X = gets.chomp.split(' ')
tmp = X.group_by { |num| num.to_i }
sorted = tmp.keys.sort

diffs = []
(sorted.count - 1).times do |num|
  diffs.push((sorted[num] - sorted[num + 1]).abs)
end

puts diffs.count === 0 ? 0 : diffs.min
0