結果

問題 No.1053 ゲーミング棒
ユーザー titia
提出日時 2020-05-15 21:36:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 25,316 KB
最終ジャッジ日時 2024-09-19 09:19:05
合計ジャッジ時間 2,770 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
B=[A[0]]
for i in range(1,N):
    if A[i]!=A[i-1]:
        B.append(A[i])
from collections import Counter
C=Counter(B)

if max(C.values())==1:
    print(0)
else:
    D=[c-1 for c in C.values()]
    if sum(D)>1:
        print(-1)
    else:
        if A[0]==A[-1]:
            print(1)
        else:
            print(-1)
0