結果

問題 No.406 鴨等間隔の法則
ユーザー arrowsarrows
提出日時 2017-01-20 20:03:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 8,336 KB
最終ジャッジ日時 2023-09-21 18:21:19
合計ジャッジ時間 3,498 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
5,424 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 71 ms
7,592 KB
testcase_05 AC 22 ms
4,904 KB
testcase_06 AC 24 ms
5,340 KB
testcase_07 AC 24 ms
5,088 KB
testcase_08 AC 68 ms
7,668 KB
testcase_09 AC 76 ms
8,336 KB
testcase_10 AC 27 ms
5,288 KB
testcase_11 AC 56 ms
7,016 KB
testcase_12 AC 34 ms
5,712 KB
testcase_13 AC 31 ms
5,560 KB
testcase_14 AC 67 ms
7,256 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 9 ms
4,384 KB
testcase_21 AC 9 ms
4,380 KB
testcase_22 AC 16 ms
4,748 KB
testcase_23 AC 37 ms
5,904 KB
testcase_24 AC 58 ms
6,840 KB
testcase_25 AC 77 ms
8,036 KB
testcase_26 AC 86 ms
8,180 KB
testcase_27 AC 36 ms
4,380 KB
testcase_28 AC 63 ms
8,156 KB
testcase_29 AC 87 ms
8,032 KB
testcase_30 AC 85 ms
8,012 KB
testcase_31 AC 73 ms
7,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    set<int> st;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
        st.insert(v[i]);
    }

    if ((int)st.size() != N) {
        cout << "NO" << endl;
        return 0;
    }
    
    sort(v.begin(), v.end());
    int d = v[1] - v[0];
    bool poss = 1;
    for (int i = 2; i < N; i++) {
        if (v[i] - v[i - 1] != d) {
            poss = 0;
            break;
        }
    }
    cout << (poss ? "YES" : "NO") << endl;
    return 0;
}
0