結果

問題 No.406 鴨等間隔の法則
ユーザー cande398cande398
提出日時 2017-10-08 21:07:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 623 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 72,500 KB
実行使用メモリ 62,384 KB
最終ジャッジ日時 2023-09-21 18:37:42
合計ジャッジ時間 17,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 433 ms
60,504 KB
testcase_01 AC 123 ms
56,000 KB
testcase_02 AC 121 ms
56,128 KB
testcase_03 AC 123 ms
55,748 KB
testcase_04 AC 592 ms
60,376 KB
testcase_05 AC 403 ms
60,768 KB
testcase_06 AC 400 ms
60,508 KB
testcase_07 AC 414 ms
61,048 KB
testcase_08 AC 565 ms
60,748 KB
testcase_09 AC 623 ms
60,704 KB
testcase_10 AC 432 ms
60,600 KB
testcase_11 AC 547 ms
60,888 KB
testcase_12 AC 468 ms
60,624 KB
testcase_13 AC 479 ms
60,740 KB
testcase_14 AC 572 ms
60,772 KB
testcase_15 AC 227 ms
59,168 KB
testcase_16 AC 245 ms
59,912 KB
testcase_17 AC 211 ms
58,820 KB
testcase_18 AC 240 ms
59,184 KB
testcase_19 AC 260 ms
60,580 KB
testcase_20 AC 277 ms
61,100 KB
testcase_21 AC 297 ms
60,964 KB
testcase_22 AC 355 ms
58,496 KB
testcase_23 AC 480 ms
61,024 KB
testcase_24 AC 536 ms
60,760 KB
testcase_25 AC 619 ms
60,996 KB
testcase_26 AC 600 ms
61,380 KB
testcase_27 AC 550 ms
60,660 KB
testcase_28 AC 566 ms
60,996 KB
testcase_29 AC 601 ms
61,664 KB
testcase_30 AC 607 ms
62,384 KB
testcase_31 AC 584 ms
61,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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