結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-15 21:41:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 572 bytes |
| コンパイル時間 | 1,623 ms |
| コンパイル使用メモリ | 173,392 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2024-09-19 09:22:50 |
| 合計ジャッジ時間 | 2,679 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 3 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
int a[200000];
int main(){
int n;cin>>n;
rep(i,n)scanf("%d",&a[i]);
set<int>se;
int s=0,g=n-1;
int cnt=0;
while(1){
int ns=s,ng=g;
if(se.count(a[s])){
puts("-1");return 0;
}
se.insert(a[s]);
while(ns<n&&a[s]==a[ns])ns++;
while(ng>=0&&a[s]==a[ng])ng--;
if(ng<ns)break;
if(g!=ng){
cnt++;
}
s=ns;g=ng;
}
cout<<cnt<<endl;
}