結果

問題 No.1053 ゲーミング棒
ユーザー RhoRho
提出日時 2020-05-15 21:43:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 174,908 KB
実行使用メモリ 9,720 KB
最終ジャッジ日時 2023-10-19 13:17:35
合計ジャッジ時間 3,276 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 AC 69 ms
9,680 KB
testcase_24 AC 82 ms
9,680 KB
testcase_25 WA -
testcase_26 AC 84 ms
9,680 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 18 ms
4,432 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 17 ms
4,496 KB
testcase_34 AC 17 ms
4,496 KB
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int a[100006];
signed main(){
    int n;cin>>n;
    rep(i,n){
        cin>>a[i];
        assert(a[i]<=n);
    }
    vector<int>v;
    int now=a[0];
    rep(i,n+1){
        if(now!=a[i]){
            v.push_back(now);
            now=a[i];
        }
    }
    set<int>S;
    int flg=0;
   rep(i,v.size()){
        if(S.find(v[i])!=S.end()){
            flg++;
            if(i-1!=v.size())flg++;
        }
        S.insert(v[i]);
    }
    if(flg>1)flg=-1;
    cout<<flg<<endl;
}
0