結果

問題 No.1053 ゲーミング棒
ユーザー 0w1
提出日時 2020-11-17 14:21:48
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 412 bytes
コンパイル時間 3,282 ms
コンパイル使用メモリ 164,124 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-07-23 08:16:48
合計ジャッジ時間 5,642 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int N; { cin >> N; }
  vector<int> A(N); { for (int i = 0; i < N; ++i) cin >> A[i]; }

  int res = 0;
  A.erase(unique(A.begin(), A.end()), A.end());
  if (A.back() == A.front()) ++res, A.pop_back();

  set<int> bag(A.begin(), A.end());
  if (bag.size() == A.size()) cout << res << endl;
  else cout << -1 << endl;
}

0