結果

問題 No.1053 ゲーミング棒
ユーザー toyuzuko
提出日時 2020-06-04 22:30:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 32,248 KB
最終ジャッジ日時 2024-11-30 08:51:32
合計ジャッジ時間 3,425 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from itertools import groupby

N = int(input())
A = list(map(int, input().split()))

def solve(arr):
    c = Counter(arr)
    g = tuple(groupby(arr))
    if len(c) == len(g):
        return True
    return False

flag = 0

while A and A[-1] == A[0]:
    A.pop()
    flag = 1
    if not A:
        flag = 0

if solve(A):
    print(int(flag))
else:
    print(-1)
0