結果

問題 No.1053 ゲーミング棒
ユーザー tanon710tanon710
提出日時 2020-05-15 23:04:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 98,772 KB
最終ジャッジ日時 2023-10-19 16:42:56
合計ジャッジ時間 3,357 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,568 KB
testcase_01 AC 36 ms
53,568 KB
testcase_02 AC 37 ms
53,568 KB
testcase_03 AC 36 ms
53,568 KB
testcase_04 AC 36 ms
53,568 KB
testcase_05 AC 36 ms
53,568 KB
testcase_06 AC 36 ms
53,568 KB
testcase_07 AC 35 ms
53,568 KB
testcase_08 AC 36 ms
53,568 KB
testcase_09 AC 38 ms
53,568 KB
testcase_10 AC 37 ms
53,568 KB
testcase_11 AC 36 ms
53,568 KB
testcase_12 AC 37 ms
53,568 KB
testcase_13 AC 36 ms
53,568 KB
testcase_14 AC 36 ms
53,568 KB
testcase_15 AC 36 ms
53,568 KB
testcase_16 AC 38 ms
53,568 KB
testcase_17 AC 36 ms
53,568 KB
testcase_18 AC 37 ms
53,568 KB
testcase_19 AC 36 ms
53,568 KB
testcase_20 AC 37 ms
53,568 KB
testcase_21 AC 36 ms
53,568 KB
testcase_22 AC 37 ms
53,568 KB
testcase_23 AC 72 ms
96,420 KB
testcase_24 AC 72 ms
96,420 KB
testcase_25 AC 74 ms
98,772 KB
testcase_26 AC 71 ms
96,420 KB
testcase_27 AC 37 ms
53,568 KB
testcase_28 AC 37 ms
53,568 KB
testcase_29 AC 36 ms
53,568 KB
testcase_30 AC 53 ms
78,396 KB
testcase_31 AC 58 ms
79,228 KB
testcase_32 AC 55 ms
78,844 KB
testcase_33 AC 57 ms
79,872 KB
testcase_34 AC 57 ms
79,232 KB
testcase_35 AC 60 ms
82,940 KB
testcase_36 AC 60 ms
83,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
arr=list(map(int,input().split()))
if n==1:
    print(0)
    exit()
if arr.count(arr[0])==n:
    print(0)
    exit()
if arr[0]==arr[-1]:
    s=set()
    s.add(arr[0])
    for i in range(n):
        if arr[i]==arr[0]:
            continue
        else:
            arr=arr[i:]
            break
    for i in range(n):
        if arr[-(i+1)]==arr[-1]:
            continue
        else:
            arr=arr[:-i]
            break
    n=len(arr)
    arr.append(0)
    for i in range(n):
        if arr[i] in s:
            print(-1)
            break
        if arr[i]==arr[i+1]:
            continue
        else:
            s.add(arr[i])
    else:
        print(1)
else:
    s=set()
    arr.append(0)
    for i in range(n):
        if arr[i] in s:
            print(-1)
            break
        if arr[i]==arr[i+1]:
            continue
        else:
            s.add(arr[i])
    else:
        print(0)
0