結果

問題 No.406 鴨等間隔の法則
ユーザー 👑 CleyL
提出日時 2020-01-16 17:00:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 75,400 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 12:45:38
合計ジャッジ時間 2,543 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i = 0; n > i; i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int k = 0;
    for(int i = 1; n > i; i++){
        if(!(a[i]-a[i-1])){
            cout << "NO" << endl;
            return 0;
        }
        if(i==1){
            k = a[i]-a[i-1];
        }else if(k != a[i]-a[i-1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}
0