結果

問題 No.406 鴨等間隔の法則
ユーザー tsuchinagatsuchinaga
提出日時 2019-02-21 12:28:06
言語 Go
(1.22.1)
結果
AC  
実行時間 1,070 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 12,824 ms
コンパイル使用メモリ 200,408 KB
実行使用メモリ 7,952 KB
最終ジャッジ日時 2023-09-21 18:59:13
合計ジャッジ時間 32,178 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 425 ms
5,684 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 952 ms
7,952 KB
testcase_05 AC 350 ms
5,672 KB
testcase_06 AC 371 ms
5,676 KB
testcase_07 AC 383 ms
5,676 KB
testcase_08 AC 937 ms
7,948 KB
testcase_09 AC 1,036 ms
7,940 KB
testcase_10 AC 424 ms
5,684 KB
testcase_11 AC 823 ms
7,948 KB
testcase_12 AC 526 ms
5,708 KB
testcase_13 AC 485 ms
5,704 KB
testcase_14 AC 866 ms
7,948 KB
testcase_15 AC 56 ms
4,376 KB
testcase_16 AC 72 ms
4,376 KB
testcase_17 AC 37 ms
4,380 KB
testcase_18 AC 81 ms
4,380 KB
testcase_19 AC 91 ms
4,376 KB
testcase_20 AC 130 ms
4,376 KB
testcase_21 AC 132 ms
4,376 KB
testcase_22 AC 235 ms
4,380 KB
testcase_23 AC 560 ms
5,708 KB
testcase_24 AC 770 ms
7,948 KB
testcase_25 AC 1,055 ms
7,940 KB
testcase_26 AC 1,070 ms
7,944 KB
testcase_27 AC 1,044 ms
7,944 KB
testcase_28 AC 1,027 ms
7,940 KB
testcase_29 AC 1,058 ms
7,944 KB
testcase_30 AC 1,043 ms
7,940 KB
testcase_31 AC 1,001 ms
7,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	_, _ = fmt.Scan(&n)

	nums := make([]int, n)
	for i := range nums {
		_, _ = fmt.Scan(&x)
		nums[i] = x
	}

	sort.Slice(nums, func(i, j int) bool {
		return nums[i] < nums[j]
	})

	diff := nums[1] - nums[0]
	for i := range nums {
		if i < 2 {
			continue
		}

		if diff == 0 || nums[i]-nums[i-1] != diff {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}
0