結果

問題 No.406 鴨等間隔の法則
ユーザー hiyorihiyori
提出日時 2017-08-24 13:49:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,929 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 75,192 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 07:09:54
合計ジャッジ時間 11,728 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 54 ms
4,376 KB
testcase_05 AC 129 ms
4,384 KB
testcase_06 AC 26 ms
4,380 KB
testcase_07 AC 23 ms
4,380 KB
testcase_08 AC 81 ms
4,380 KB
testcase_09 AC 111 ms
4,384 KB
testcase_10 AC 67 ms
4,376 KB
testcase_11 AC 120 ms
4,380 KB
testcase_12 AC 109 ms
4,380 KB
testcase_13 AC 29 ms
4,380 KB
testcase_14 AC 1,318 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 18 ms
4,380 KB
testcase_20 AC 33 ms
4,380 KB
testcase_21 AC 35 ms
4,376 KB
testcase_22 AC 101 ms
4,380 KB
testcase_23 AC 82 ms
4,380 KB
testcase_24 AC 1,020 ms
4,376 KB
testcase_25 AC 149 ms
4,376 KB
testcase_26 AC 1,929 ms
4,384 KB
testcase_27 AC 37 ms
4,384 KB
testcase_28 AC 87 ms
4,384 KB
testcase_29 AC 1,924 ms
4,380 KB
testcase_30 AC 1,859 ms
4,380 KB
testcase_31 AC 146 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(i=0; i<n; i++)
#define rep2(i,a,b) for(i=a; i<b; i++)
using namespace std;

int vector_check(vector<int> v)
{
  int i, j;
  rep(i,v.size()) {
    rep2(j,i+1,v.size()) {
        if(v[i]==v[j]) { return 0; }
        else continue;
    }
  }
  return 1;
}

void end_NO ()
{
    cout << "NO" << endl;
}

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    int i,num;
    rep(i,n) {
        cin>>num;
        v[i] = num;
    }
    
    sort(v.begin(), v.end());
    
    if(vector_check(v) == 0) { end_NO(); return 0; }
    
    rep(i,v.size()-1) {
        if(i==0) { num = v[i+1] - v[i]; }
        else if(i>=1) {
            if(num!=v[i+1]-v[i]) { end_NO(); return 0; }
        }
    }
    

    cout << "YES" << endl;
     
    return 0;
}
0