結果

問題 No.1053 ゲーミング棒
ユーザー megumeguromegumeguro
提出日時 2020-05-16 12:10:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 534 bytes
コンパイル時間 1,807 ms
コンパイル使用メモリ 81,460 KB
実行使用メモリ 285,568 KB
最終ジャッジ日時 2023-10-22 03:21:53
合計ジャッジ時間 8,405 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,360 KB
testcase_01 AC 42 ms
53,360 KB
testcase_02 AC 43 ms
53,360 KB
testcase_03 AC 42 ms
53,360 KB
testcase_04 AC 42 ms
53,360 KB
testcase_05 AC 42 ms
53,360 KB
testcase_06 AC 41 ms
53,360 KB
testcase_07 AC 41 ms
53,360 KB
testcase_08 AC 41 ms
53,360 KB
testcase_09 AC 42 ms
53,360 KB
testcase_10 AC 42 ms
53,360 KB
testcase_11 AC 41 ms
53,360 KB
testcase_12 AC 42 ms
53,360 KB
testcase_13 AC 41 ms
53,360 KB
testcase_14 AC 41 ms
53,360 KB
testcase_15 AC 41 ms
53,360 KB
testcase_16 AC 41 ms
53,360 KB
testcase_17 AC 41 ms
53,360 KB
testcase_18 AC 41 ms
53,360 KB
testcase_19 AC 41 ms
53,360 KB
testcase_20 AC 41 ms
53,360 KB
testcase_21 AC 42 ms
53,360 KB
testcase_22 AC 42 ms
53,360 KB
testcase_23 AC 270 ms
92,524 KB
testcase_24 AC 260 ms
92,544 KB
testcase_25 AC 261 ms
92,540 KB
testcase_26 AC 263 ms
92,544 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
from collections import deque
N = int(input())
A = list(map(int,input().split()))

A = deque(A)
cnt = 0
while True:
    a1 = A.popleft()
    if a1 == A[-1]:
        A.append(a1)
        cnt += 1
    else:
        A = deque([a1]) + A
        break
#print(A)
L = [False] * (N+1)
a = [A[0]]
for i in range(N-1):
    if A[i+1] != A[i]:
        a.append(A[i+1])
    #print(A)
flg = True
for i in range(len(a)):
    if L[a[i]]:
        flg = False
    else:
        L[a[i]] = True

if flg:
    print(cnt)
else:
    print(-1)
0