結果

問題 No.406 鴨等間隔の法則
ユーザー hiyorihiyori
提出日時 2017-08-24 13:49:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,950 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 76,728 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 01:15:23
合計ジャッジ時間 11,753 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 60 ms
5,376 KB
testcase_05 AC 131 ms
5,376 KB
testcase_06 AC 28 ms
5,376 KB
testcase_07 AC 26 ms
5,376 KB
testcase_08 AC 87 ms
5,376 KB
testcase_09 AC 115 ms
5,376 KB
testcase_10 AC 70 ms
5,376 KB
testcase_11 AC 124 ms
5,376 KB
testcase_12 AC 112 ms
5,376 KB
testcase_13 AC 31 ms
5,376 KB
testcase_14 AC 1,338 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 16 ms
5,376 KB
testcase_19 AC 19 ms
5,376 KB
testcase_20 AC 34 ms
5,376 KB
testcase_21 AC 37 ms
5,376 KB
testcase_22 AC 103 ms
5,376 KB
testcase_23 AC 86 ms
5,376 KB
testcase_24 AC 1,035 ms
5,376 KB
testcase_25 AC 156 ms
5,376 KB
testcase_26 AC 1,944 ms
5,376 KB
testcase_27 AC 42 ms
5,376 KB
testcase_28 AC 93 ms
5,376 KB
testcase_29 AC 1,950 ms
5,376 KB
testcase_30 AC 1,882 ms
5,376 KB
testcase_31 AC 150 ms
5,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