結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2016-08-05 22:53:31 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 563 bytes |
コンパイル時間 | 9,732 ms |
コンパイル使用メモリ | 221,856 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 11:24:10 |
合計ジャッジ時間 | 11,008 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
package main import ( "fmt" "sort" "bufio" "os" "strconv" ) func main() { sc.Split(bufio.ScanWords) N := nextInt() x := make([]int, N) for i := 0; i < N; i++ { x[i] = nextInt() } sort.Ints(x) z := x[1] - x[0] flag := true for i := 1; i < N; i++ { if x[i]-x[i-1] != z || z == 0 { flag = false } } if flag { fmt.Println("YES") } else { fmt.Println("NO") } } var sc = bufio.NewScanner(os.Stdin) func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }