結果

問題 No.1053 ゲーミング棒
ユーザー uni_python
提出日時 2020-05-15 22:27:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 81,024 KB
最終ジャッジ日時 2024-09-19 11:19:18
合計ジャッジ時間 2,750 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N=I()
    A=LI()
    now=0
    use=[0]*(N)
    for i in range(N):
        if now!=A[i]:
            use[A[i]-1]+=1
        now=A[i]
        
    if max(use)<=1:
        print(0)
    else:
        if A[0]==A[-1]:
            use[A[0]-1]-=1
        
        if max(use)<=1:
            print(1)
        else:
            print(-1)
    
    


main()
0