結果

問題 No.406 鴨等間隔の法則
ユーザー kat0rik
提出日時 2019-09-20 09:32:53
言語 Go
(1.23.4)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 9,916 ms
コンパイル使用メモリ 235,488 KB
実行使用メモリ 6,812 KB
最終ジャッジ日時 2024-07-07 12:44:44
合計ジャッジ時間 11,206 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	sort.Ints(a)
	ok := true
	for i := 1; i+1 < n; i++ {
		if a[i-1] == a[i] || a[i]-a[i-1] != a[i+1]-a[i] {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
0