結果

問題 No.1053 ゲーミング棒
ユーザー brthyyjpbrthyyjp
提出日時 2020-05-15 21:52:19
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 116,968 KB
最終ジャッジ日時 2023-10-19 13:29:52
合計ジャッジ時間 3,461 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,360 KB
testcase_01 AC 44 ms
53,360 KB
testcase_02 AC 44 ms
53,360 KB
testcase_03 AC 44 ms
53,360 KB
testcase_04 AC 43 ms
53,360 KB
testcase_05 AC 43 ms
53,360 KB
testcase_06 AC 43 ms
53,360 KB
testcase_07 AC 44 ms
53,360 KB
testcase_08 AC 43 ms
53,360 KB
testcase_09 AC 43 ms
53,360 KB
testcase_10 AC 45 ms
53,360 KB
testcase_11 AC 44 ms
53,360 KB
testcase_12 AC 43 ms
53,360 KB
testcase_13 AC 42 ms
53,360 KB
testcase_14 AC 43 ms
53,360 KB
testcase_15 AC 43 ms
53,360 KB
testcase_16 AC 43 ms
53,360 KB
testcase_17 AC 42 ms
53,360 KB
testcase_18 AC 42 ms
53,360 KB
testcase_19 AC 42 ms
53,360 KB
testcase_20 AC 44 ms
53,360 KB
testcase_21 AC 42 ms
53,360 KB
testcase_22 AC 42 ms
53,360 KB
testcase_23 AC 100 ms
116,964 KB
testcase_24 AC 99 ms
116,964 KB
testcase_25 AC 100 ms
116,968 KB
testcase_26 AC 100 ms
116,968 KB
testcase_27 AC 40 ms
53,344 KB
testcase_28 AC 43 ms
53,360 KB
testcase_29 AC 38 ms
53,344 KB
testcase_30 AC 57 ms
76,116 KB
testcase_31 AC 72 ms
85,912 KB
testcase_32 AC 71 ms
83,588 KB
testcase_33 AC 71 ms
85,912 KB
testcase_34 AC 71 ms
85,912 KB
testcase_35 AC 73 ms
86,392 KB
testcase_36 AC 75 ms
86,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if len(set(A)) == 1:
    print(0)
    exit()

from collections import deque
B = deque(A)
temp = A[0]
flag = False
while True:
    x = B.pop()
    if x != temp:
        B.append(x)
        break
    else:
        B.appendleft(x)
        flag = True

if flag:
    ans = 1
else:
    ans = 0

S = set()
C = list(B)
temp = C[0]
for i in range(n):
    if C[i] != temp:
        if C[i] in S:
            print(-1)
            exit()
        else:
            S.add(temp)
            temp = C[i]
else:
    print(ans)
0