結果

問題 No.1053 ゲーミング棒
ユーザー yuki60039yuki60039
提出日時 2020-05-15 22:55:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 886 bytes
コンパイル時間 4,085 ms
コンパイル使用メモリ 173,036 KB
実行使用メモリ 9,912 KB
最終ジャッジ日時 2023-10-19 16:10:36
合計ジャッジ時間 5,237 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
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 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 2 ms
4,348 KB
testcase_10 RE -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 RE -
testcase_14 AC 3 ms
4,348 KB
testcase_15 RE -
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 RE -
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 AC 2 ms
4,348 KB
testcase_23 AC 41 ms
9,820 KB
testcase_24 AC 50 ms
9,912 KB
testcase_25 AC 50 ms
9,324 KB
testcase_26 AC 48 ms
9,512 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,348 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 22 ms
6,528 KB
testcase_34 AC 21 ms
6,564 KB
testcase_35 RE -
testcase_36 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    vector<vector<int>>color;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(color.size()<a[i])color.resize(a[i]);
        color[a[i]-1].push_back(i);
    }
    int rev=0;
    for(int i=0;i<color.size();i++){
        for(int j=0;j<color[i].size()-1;j++){
            if(color[i][j]+1<color[i][j+1]){
                if(color[i][0]!=0 || color[i].back()!=n-1){
                    cout<<"-1"<<endl;
                    return 0;
                }
                rev++;
                for(int k=j+1;k<color[i].size()-1;k++){
                    if(color[i][k]+1<color[i][k+1]){
                        cout<<"-1"<<endl;
                        return 0;
                    }
                }
                break;
            }
        }
    }
    cout<<rev<<endl;
    return 0;
}
0