結果

問題 No.1053 ゲーミング棒
ユーザー rlangevinrlangevin
提出日時 2023-04-28 12:44:56
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 584 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,508 KB
実行使用メモリ 89,536 KB
最終ジャッジ日時 2024-04-28 18:43:42
合計ジャッジ時間 3,878 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,504 KB
testcase_01 RE -
testcase_02 AC 42 ms
53,248 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 42 ms
53,632 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 41 ms
53,760 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 42 ms
53,760 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 70 ms
86,528 KB
testcase_26 RE -
testcase_27 AC 41 ms
53,248 KB
testcase_28 AC 41 ms
53,632 KB
testcase_29 AC 41 ms
53,120 KB
testcase_30 AC 65 ms
84,608 KB
testcase_31 AC 68 ms
86,400 KB
testcase_32 AC 66 ms
86,016 KB
testcase_33 AC 69 ms
86,656 KB
testcase_34 AC 71 ms
86,912 KB
testcase_35 AC 74 ms
88,320 KB
testcase_36 AC 73 ms
88,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
A = list(map(int, input().split()))
if N == 2:
    print(0)
    exit()

ans = 0
if A[0] == A[-1]:
    c = A[0]
    A = deque(A)
    while A:
        if A[0] == c:
            A.popleft()
        else:
            break
    while A:
        if A[-1] == c:
            A.pop()
        else:
            break
    A = list(A)
    if A == []:
        print(0)
        exit()
    ans = 1

seen = [0] * (N + 1)
pre = -1
for a in A:
    if (a != pre and seen[a]) or a == c:
        print(-1)
        exit()
    pre = a
    seen[a] = 1

print(ans)
0