結果

問題 No.1053 ゲーミング棒
ユーザー わなわなわなわな
提出日時 2020-05-16 03:56:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 753 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 74,460 KB
実行使用メモリ 4,976 KB
最終ジャッジ日時 2023-10-20 00:20:49
合計ジャッジ時間 2,384 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++){
        cin >>  a[i];
        a[i]--;
    }
    vector<int> zi;
    zi.push_back(a[0]);
    for(int i = 1; i < N; i++){
        if(a[i] != a[i - 1]) zi.push_back(a[i]);
    }
    vector<int> cnt(N, 0);
    for(int i = 0; i < zi.size(); i++){
        cnt[zi[i]]++;
        if(cnt[zi[i]] > 2){
            cout << -1 << endl;
            return 0;
        }
        if(cnt[zi[i]] == 2 && i == N - 1){
            cout << 1 << endl;
            return 0;
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}
0