結果
| 問題 | 
                            No.406 鴨等間隔の法則
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-10-29 17:29:32 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 714 bytes | 
| コンパイル時間 | 3,862 ms | 
| コンパイル使用メモリ | 79,764 KB | 
| 実行使用メモリ | 41,892 KB | 
| 最終ジャッジ日時 | 2024-11-07 12:55:17 | 
| 合計ジャッジ時間 | 9,550 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 3 | 
| other | RE * 29 | 
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class No406 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int count = s.nextInt();
        int[] arr = Arrays.stream(s.nextLine().split(" "))
            .mapToInt(Integer::parseInt)
            .toArray();
        Arrays.sort(arr);
        String out = "YES";
        int diff = arr[1] - arr[0];
        if (diff == 0) {
            out = "NO";
        } else {
            for (int i = 2; i < count; i++) {
                if (arr[i] - arr[i - 1] != diff) {
                    out = "NO";
                    break;
                }
            }
        }
        System.out.println(out);
    }
}