結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-04 14:04:25 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 5,000 ms |
| コード長 | 627 bytes |
| コンパイル時間 | 15,848 ms |
| コンパイル使用メモリ | 218,948 KB |
| 実行使用メモリ | 5,504 KB |
| 最終ジャッジ日時 | 2024-07-08 03:28:47 |
| 合計ジャッジ時間 | 15,798 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
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)
}
}