結果

問題 No.1053 ゲーミング棒
ユーザー ああいい
提出日時 2022-02-23 15:05:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 96,256 KB
最終ジャッジ日時 2024-07-01 14:46:30
合計ジャッジ時間 3,107 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N = int(input())
A = list(map(int,input().split()))
ans = 0
while A and A[-1] == A[0]:
    A.pop()
    ans = 1
if not A:
    print(0)
    exit()

s =set()
left = 0
while left < len(A):
    if A[left] not in s:
        s.add(A[left])
        right = left
        while right < len(A) and A[right] == A[left]:
            right += 1
        left = right
    else:
        print(-1)
        exit()
print(ans)
0