結果

問題 No.1053 ゲーミング棒
コンテスト
ユーザー toyuzuko
提出日時 2020-06-04 22:30:07
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 82 ms / 2,000 ms
+ 527µs
コード長 393 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,592 KB
実行使用メモリ 33,456 KB
最終ジャッジ日時 2026-10-15 17:43:24
合計ジャッジ時間 3,549 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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