結果

問題 No.135 とりあえず1次元の問題
ユーザー k.hk.h
提出日時 2019-08-04 13:39:29
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 12,839 ms
コンパイル使用メモリ 206,460 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 10:23:36
合計ジャッジ時間 12,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())
	xs := make([]int, N)
	sc.Scan()
	strs := strings.Split(sc.Text(), " ")
	for i := range strs {
		xs[i], _ = strconv.Atoi(strs[i])
	}
	sort.Ints(xs)
	min := 1000001
	for i := 0; i < N-1; i++ {
		if xs[i+1]-xs[i] < min && xs[i+1] != xs[i] {
			min = xs[i+1] - xs[i]
		}
	}
	if min == 1000001 {
		fmt.Println("0")
	} else {
		fmt.Println(min)
	}
}
0