結果

問題 No.406 鴨等間隔の法則
ユーザー hibit_athibit_at
提出日時 2022-08-30 14:00:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 2,218 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 117,432 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-04-24 23:46:42
合計ジャッジ時間 4,710 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
6,016 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 71 ms
8,192 KB
testcase_05 AC 28 ms
5,632 KB
testcase_06 AC 30 ms
5,632 KB
testcase_07 AC 29 ms
5,632 KB
testcase_08 AC 71 ms
8,064 KB
testcase_09 AC 78 ms
8,448 KB
testcase_10 AC 33 ms
5,888 KB
testcase_11 AC 60 ms
7,432 KB
testcase_12 AC 40 ms
6,360 KB
testcase_13 AC 38 ms
6,272 KB
testcase_14 AC 58 ms
7,424 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 7 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 43 ms
6,504 KB
testcase_24 AC 52 ms
6,924 KB
testcase_25 AC 79 ms
8,576 KB
testcase_26 AC 70 ms
8,320 KB
testcase_27 AC 42 ms
5,376 KB
testcase_28 AC 73 ms
8,704 KB
testcase_29 AC 71 ms
8,448 KB
testcase_30 AC 68 ms
8,448 KB
testcase_31 AC 76 ms
8,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <stack>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define all(A) A.begin(), A.end()
#define itr(A, l, r) A.begin() + l, A.begin() + r
#define debug(var) cout << #var << " = " << var << endl;
typedef long long ll;

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p)
{
    is >> p.first >> p.second;
    return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < (int)v.size(); i++)
    {
        os << v[i] << (i + 1 != (int)v.size() ? " " : "");
    }
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v)
{
    for (int i = 0; i < (int)v.size(); i++)
    {
        os << v[i] << endl;
    }
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<vector<vector<T>>> &v)
{
    for (int i = 0; i < (int)v.size(); i++)
    {
        os << "i = " << i << endl;
        os << v[i];
    }
    return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &in : v)
        is >> in;
    return is;
}

template <typename T, typename S>
ostream &operator<<(ostream &os, map<T, S> &mp)
{
    for (auto &[key, val] : mp)
    {
        os << key << ":" << val << " ";
    }
    cout << endl;
    return os;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(all(a));
    map<int, int> coordinate;
    rep(i, n)
    {
        coordinate[a[i]]++;
    }
    map<int, int> mp;
    rep(i, n - 1)
    {
        int span = a[i + 1] - a[i];
        mp[span]++;
    }
    if (mp.size() == 1 && coordinate.size() == n)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}
0