結果

問題 No.406 鴨等間隔の法則
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-19 20:29:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 636 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 71,720 KB
実行使用メモリ 62,504 KB
最終ジャッジ日時 2023-09-21 18:30:55
合計ジャッジ時間 17,966 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 451 ms
60,580 KB
testcase_01 AC 125 ms
55,740 KB
testcase_02 AC 126 ms
55,648 KB
testcase_03 AC 128 ms
55,716 KB
testcase_04 AC 616 ms
60,616 KB
testcase_05 AC 406 ms
60,660 KB
testcase_06 AC 418 ms
60,628 KB
testcase_07 AC 424 ms
60,536 KB
testcase_08 AC 581 ms
60,592 KB
testcase_09 AC 636 ms
60,852 KB
testcase_10 AC 437 ms
60,680 KB
testcase_11 AC 552 ms
60,772 KB
testcase_12 AC 495 ms
61,024 KB
testcase_13 AC 463 ms
60,400 KB
testcase_14 AC 576 ms
61,004 KB
testcase_15 AC 232 ms
59,036 KB
testcase_16 AC 255 ms
59,920 KB
testcase_17 AC 216 ms
58,968 KB
testcase_18 AC 246 ms
59,632 KB
testcase_19 AC 267 ms
60,468 KB
testcase_20 AC 293 ms
60,516 KB
testcase_21 AC 299 ms
60,436 KB
testcase_22 AC 355 ms
60,620 KB
testcase_23 AC 501 ms
58,552 KB
testcase_24 AC 549 ms
60,400 KB
testcase_25 AC 634 ms
60,540 KB
testcase_26 AC 610 ms
60,876 KB
testcase_27 AC 567 ms
60,684 KB
testcase_28 AC 566 ms
60,488 KB
testcase_29 AC 608 ms
61,472 KB
testcase_30 AC 598 ms
62,504 KB
testcase_31 AC 597 ms
60,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] x = new int[N];
    for(int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }
    Arrays.sort(x);
    String ans = "YES";
    if(x[1] == x[0]) ans = "NO";
    for(int i = 2; i < N; i++) {
      if(x[i] - x[i - 1] != x[1] - x[0]) {
        ans = "NO";
        break;
      }
    }
    System.out.println(ans);
  }
}
0