結果

問題 No.406 鴨等間隔の法則
ユーザー Masanari KIMURAMasanari KIMURA
提出日時 2016-08-05 22:56:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,934 ms / 2,000 ms
コード長 3,912 bytes
コンパイル時間 1,230 ms
コンパイル使用メモリ 105,256 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-06 23:31:57
合計ジャッジ時間 11,928 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 102 ms
4,376 KB
testcase_05 AC 69 ms
4,384 KB
testcase_06 AC 31 ms
4,380 KB
testcase_07 AC 44 ms
4,376 KB
testcase_08 AC 75 ms
4,380 KB
testcase_09 AC 38 ms
4,380 KB
testcase_10 AC 67 ms
4,380 KB
testcase_11 AC 117 ms
4,376 KB
testcase_12 AC 115 ms
4,384 KB
testcase_13 AC 32 ms
4,376 KB
testcase_14 AC 1,311 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 5 ms
4,384 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 18 ms
4,384 KB
testcase_20 AC 33 ms
4,380 KB
testcase_21 AC 35 ms
4,380 KB
testcase_22 AC 101 ms
4,380 KB
testcase_23 AC 34 ms
4,380 KB
testcase_24 AC 1,013 ms
4,380 KB
testcase_25 AC 41 ms
4,376 KB
testcase_26 AC 1,934 ms
4,380 KB
testcase_27 AC 36 ms
4,380 KB
testcase_28 AC 62 ms
4,376 KB
testcase_29 AC 1,926 ms
4,380 KB
testcase_30 AC 1,841 ms
4,380 KB
testcase_31 AC 51 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion


// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
#pragma endregion


// 素数
#pragma region PRIME
bool is_prime(unsigned n) {
  switch(n) {
    case 0:
    case 1: return false;
    case 2: return true;
  }
  if (n%2==0) return false;
  for (unsigned i=3; i*i<=n; i+=2)
    if (n%i==0) return false;
  return true;
}
#pragma endregion


// 大文字/小文字変換
#pragma region TRANSFORM
void mutal_tr(string &s) {
  for(int i=s.size(); i--;) {
    if(islower(s[i])) s[i] = toupper(s[i]);
    else if (isupper(s[i])) s[i] = tolower(s[i]);
  }
}
void to_upper(string &s) { for(int i=s.size(); i--;) s[i] = toupper(s[i]); }
void to_lower(string &s) { for(int i=s.size(); i--;) s[i] = tolower(s[i]); }
#pragma endregion


// 集合
#pragma region SET
template<class T>
set<T> intersection(const set<T>& sa, const set<T>& sb) {
  set<T> ret;
  for(T a : sa) if(sb.find(a) != sb.end()) ret.insert(a);
  return ret;
}
#pragma endregion

// Union Find
#pragma region UF
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if(x!=y) {
      if(data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};
#pragma endregion


// 定数
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion

int main()
{
    int N;
    cin >> N;
    vi v;
    rep(i,N) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    rep(i,N) {
        REP(j,i+1,N) {
            if(v[i]==v[j]) {
                P("NO");
                return 0;
            }
        }
    }
    sort(v);
    int d = v[1] - v[0];
    rep(i,N-1) {
      if(v[i+1]-v[i]!=d) {
          P("NO");
          return 0;
      }
    }
    P("YES");
    return 0;
}

0