結果

問題 No.406 鴨等間隔の法則
ユーザー jin128jin128
提出日時 2016-08-30 01:34:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 634 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 72,664 KB
実行使用メモリ 62,764 KB
最終ジャッジ日時 2023-09-21 18:19:59
合計ジャッジ時間 17,948 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 436 ms
62,764 KB
testcase_01 AC 127 ms
55,860 KB
testcase_02 AC 125 ms
55,944 KB
testcase_03 AC 128 ms
56,020 KB
testcase_04 AC 580 ms
58,880 KB
testcase_05 AC 409 ms
60,392 KB
testcase_06 AC 436 ms
60,672 KB
testcase_07 AC 430 ms
60,556 KB
testcase_08 AC 597 ms
60,664 KB
testcase_09 AC 634 ms
61,400 KB
testcase_10 AC 439 ms
62,480 KB
testcase_11 AC 557 ms
60,704 KB
testcase_12 AC 474 ms
60,728 KB
testcase_13 AC 464 ms
60,448 KB
testcase_14 AC 566 ms
60,744 KB
testcase_15 AC 232 ms
59,304 KB
testcase_16 AC 248 ms
59,868 KB
testcase_17 AC 215 ms
58,588 KB
testcase_18 AC 245 ms
59,248 KB
testcase_19 AC 264 ms
59,716 KB
testcase_20 AC 283 ms
61,396 KB
testcase_21 AC 302 ms
60,288 KB
testcase_22 AC 353 ms
60,788 KB
testcase_23 AC 509 ms
62,700 KB
testcase_24 AC 551 ms
60,684 KB
testcase_25 AC 629 ms
61,644 KB
testcase_26 AC 606 ms
61,628 KB
testcase_27 AC 572 ms
60,744 KB
testcase_28 AC 576 ms
60,624 KB
testcase_29 AC 602 ms
59,560 KB
testcase_30 AC 603 ms
62,376 KB
testcase_31 AC 607 ms
60,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

class S25_duck{
  public static void main(String[] args){
      int n;
      String ans = "YES";
      Scanner sc = new Scanner(System.in);

      n = sc.nextInt();
      int[] duck = new int[n];

      for(int i = 0; i < n; i++){
        duck[i] = sc.nextInt();
      }

      Arrays.sort(duck);

      int a = duck[1] - duck[0];
      for(int i = 2; i < n; i++){
        if((duck[i] - duck[i-1]) != a || duck[i] == duck[i-1]){
          ans = "NO";
          break;
        }
      }
      System.out.println(ans);
  }
}
0