結果

問題 No.135 とりあえず1次元の問題
ユーザー tnoda_tnoda_
提出日時 2015-01-26 00:20:01
言語 Go
(1.22.1)
結果
AC  
実行時間 763 ms / 5,000 ms
コード長 482 bytes
コンパイル時間 10,060 ms
コンパイル使用メモリ 207,432 KB
実行使用メモリ 9,276 KB
最終ジャッジ日時 2023-08-31 01:26:03
合計ジャッジ時間 14,731 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 708 ms
9,232 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 763 ms
7,956 KB
testcase_22 AC 714 ms
9,276 KB
evil01.txt AC 703 ms
9,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"sort"
)

func min(x, y int) int {
	if y < x {
		return y
	}
	return x
}

const inf = 1 << 30

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[int]bool)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		m[x] = true
	}
	a := make([]int, 0, n)
	for k := range m {
		a = append(a, k)
	}
	sort.Ints(a)
	if len(a) < 2 {
		fmt.Println(0)
		return
	}
	res := inf
	for i := 1; i < len(a); i++ {
		res = min(res, a[i]-a[i-1])
	}
	fmt.Println(res)
}
0