結果
問題 | No.716 距離 |
ユーザー |
|
提出日時 | 2024-03-30 14:18:28 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 500 bytes |
コンパイル時間 | 14,518 ms |
コンパイル使用メモリ | 227,220 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 17:29:30 |
合計ジャッジ時間 | 12,746 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 |
ソースコード
// No.716 距離package mainimport ("bufio""fmt""os""sort""strconv")func main() {var sc = bufio.NewScanner(os.Stdin)sc.Split(bufio.ScanWords)nextInt := func() int {sc.Scan()i, _ := strconv.Atoi(sc.Text())return i}var n = nextInt()var a = make([]int, n)for i := 0; i < n; i++ {a[i] = nextInt()}sort.Ints(a)minDiff := a[1] - a[0]for j := 1; j < n; j++ {minDiff = min(minDiff, a[j]-a[j-1])}fmt.Println(minDiff)fmt.Println(a[len(a)-1] - a[0])}