結果

問題 No.1053 ゲーミング棒
ユーザー rlangevinrlangevin
提出日時 2023-04-28 12:46:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,132 KB
実行使用メモリ 89,224 KB
最終ジャッジ日時 2024-04-28 18:44:09
合計ジャッジ時間 3,148 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
54,400 KB
testcase_01 AC 43 ms
54,236 KB
testcase_02 AC 42 ms
54,428 KB
testcase_03 AC 42 ms
53,752 KB
testcase_04 AC 41 ms
55,180 KB
testcase_05 AC 42 ms
54,480 KB
testcase_06 AC 42 ms
54,832 KB
testcase_07 AC 42 ms
53,816 KB
testcase_08 AC 42 ms
54,656 KB
testcase_09 AC 40 ms
55,056 KB
testcase_10 AC 42 ms
54,556 KB
testcase_11 AC 42 ms
54,264 KB
testcase_12 AC 42 ms
54,428 KB
testcase_13 AC 42 ms
53,664 KB
testcase_14 AC 43 ms
54,352 KB
testcase_15 AC 42 ms
53,792 KB
testcase_16 AC 42 ms
54,140 KB
testcase_17 AC 42 ms
54,532 KB
testcase_18 AC 42 ms
54,996 KB
testcase_19 AC 41 ms
54,436 KB
testcase_20 AC 41 ms
54,168 KB
testcase_21 AC 42 ms
55,672 KB
testcase_22 AC 41 ms
54,724 KB
testcase_23 AC 66 ms
83,796 KB
testcase_24 AC 66 ms
82,296 KB
testcase_25 AC 70 ms
87,828 KB
testcase_26 AC 66 ms
83,420 KB
testcase_27 AC 42 ms
55,200 KB
testcase_28 AC 41 ms
53,908 KB
testcase_29 AC 41 ms
54,112 KB
testcase_30 AC 65 ms
86,768 KB
testcase_31 AC 68 ms
87,096 KB
testcase_32 AC 67 ms
87,148 KB
testcase_33 AC 70 ms
87,604 KB
testcase_34 AC 69 ms
87,460 KB
testcase_35 AC 74 ms
88,672 KB
testcase_36 AC 74 ms
89,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

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

ans = 0
c = -1
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