結果

問題 No.406 鴨等間隔の法則
ユーザー yuki2006yuki2006
提出日時 2016-08-03 21:18:41
言語 Go
(1.21.3)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 10,810 ms
コンパイル使用メモリ 209,688 KB
実行使用メモリ 7,796 KB
最終ジャッジ日時 2023-09-21 17:39:57
合計ジャッジ時間 12,566 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
7,784 KB
testcase_01 AC 1 ms
5,492 KB
testcase_02 AC 2 ms
5,492 KB
testcase_03 AC 1 ms
5,492 KB
testcase_04 AC 21 ms
7,784 KB
testcase_05 AC 10 ms
7,780 KB
testcase_06 AC 11 ms
7,784 KB
testcase_07 AC 10 ms
7,780 KB
testcase_08 AC 20 ms
7,788 KB
testcase_09 AC 22 ms
7,760 KB
testcase_10 AC 11 ms
7,784 KB
testcase_11 AC 20 ms
7,796 KB
testcase_12 AC 13 ms
7,792 KB
testcase_13 AC 12 ms
7,788 KB
testcase_14 AC 19 ms
7,772 KB
testcase_15 AC 1 ms
5,504 KB
testcase_16 AC 2 ms
5,508 KB
testcase_17 AC 2 ms
5,508 KB
testcase_18 AC 2 ms
5,504 KB
testcase_19 AC 3 ms
5,504 KB
testcase_20 AC 3 ms
5,512 KB
testcase_21 AC 4 ms
5,508 KB
testcase_22 AC 6 ms
7,568 KB
testcase_23 AC 15 ms
7,788 KB
testcase_24 AC 18 ms
7,796 KB
testcase_25 AC 23 ms
7,760 KB
testcase_26 AC 23 ms
7,756 KB
testcase_27 AC 6 ms
7,796 KB
testcase_28 AC 5 ms
7,796 KB
testcase_29 AC 23 ms
7,760 KB
testcase_30 AC 22 ms
7,760 KB
testcase_31 AC 22 ms
7,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func main() {
	N := largeInt()
	x := largeIntArray()

	sort.Ints(x)

	diff := x[1] - x[0]
	if diff == 0 {
		fmt.Println("NO")
		return
	}
	for i := 1; i < N; i++ {
		if diff != x[i] - x[i - 1] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func largeInt() (ret int) {
	s := readLine()
	ret, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return
}

func largeIntArray() []int {
	s := readLine()
	vs := strings.Split(s, " ")
	N := len(vs)
	data := make([]int, N)
	for i := 0; i < N; i++ {
		var e error
		data[i], e = strconv.Atoi(vs[i])
		if (e != nil) {
			panic(e)
		}
	}
	return data
}
0