結果

問題 No.1053 ゲーミング棒
ユーザー i_mrhji_mrhj
提出日時 2020-05-15 22:14:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,529 bytes
コンパイル時間 960 ms
コンパイル使用メモリ 100,684 KB
実行使用メモリ 9,712 KB
最終ジャッジ日時 2023-10-19 14:43:32
合計ジャッジ時間 5,420 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 AC 2 ms
4,348 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
testcase_25 WA -
testcase_26 AC 44 ms
9,452 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 19 ms
5,888 KB
testcase_31 WA -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 19 ms
6,684 KB
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}




int main(void) {

  int n, a[100100];
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }


  vector< vector<int> > v(n + 10);

  vector<int> b;
  int k = a[0];
  int j = 0;
  while (a[j] == a[0]) j++;
  for (int i = j; i < n; i++) b.push_back(a[i]);

  if (j == n) {
    cout << 0 << endl;
    return 0;
  }

  rep(i, b.size()) v[b[i]].push_back(i);

  bool f = true;
  rep(i, n) {
    if (v[i].size() > 1) {
      rep(t, v[i].size()-1) {
	if (v[i][t+1]-v[t][j] > 1) f = false;
	if (!f) break;
      }
    }
    if (!f) break;
  }

  if (!f) cout << -1 << endl;
  else {
    if (*v[a[0]].end() != n - j) cout << -1 << endl;
    else if (a[0] == a[n-1]) cout << 1 << endl;
    else cout << 0 << endl;
  }

  return 0;

}
0