結果

問題 No.135 とりあえず1次元の問題
ユーザー k.hk.h
提出日時 2019-08-04 14:04:25
言語 Go
(1.22.1)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 16,032 ms
コンパイル使用メモリ 207,116 KB
実行使用メモリ 7,776 KB
最終ジャッジ日時 2023-09-22 11:40:20
合計ジャッジ時間 15,664 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

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

func toInt(bytes []byte) int {
	num, _ := strconv.Atoi(string(bytes))
	return num
}

func main() {
	rdr := bufio.NewReaderSize(os.Stdin, 8*100001)
	l, _, _ := rdr.ReadLine()
	N := toInt(l)
	l, _, _ = rdr.ReadLine()
	xs := make([]int, N)
	strs := strings.Split(string(l), " ")
	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