結果
| 問題 | 
                            No.406 鴨等間隔の法則
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-03-19 16:59:12 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 524 bytes | 
| コンパイル時間 | 515 ms | 
| コンパイル使用メモリ | 37,060 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-12-31 23:05:16 | 
| 合計ジャッジ時間 | 6,042 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 RE * 24 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d",&x[i]);
      |         ~~~~~^~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
#include <algorithm>
int main(){
    //input
    int N;
    scanf("%d",&N);
    int x[10000];
    for (int i = 0;i < N;i++){
        scanf("%d",&x[i]);
    }
    //sort array x
    std::sort(x,x+N);
    //diffrence of x_i and x_i+1
    int d = x[1]-x[0];
    if (d == 0){
        printf("NO\n");
        return 0;
    }
    //search
    for (int i = 0;i <= N-2;i++){
        if (x[i+1]-x[i] != d){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}