結果

問題 No.1053 ゲーミング棒
ユーザー GrayCoderGrayCoder
提出日時 2020-05-16 06:54:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 902 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 11,784 KB
実行使用メモリ 23,592 KB
最終ジャッジ日時 2023-10-21 17:34:42
合計ジャッジ時間 2,880 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,044 KB
testcase_01 AC 29 ms
10,044 KB
testcase_02 AC 29 ms
10,044 KB
testcase_03 AC 29 ms
10,044 KB
testcase_04 AC 28 ms
10,044 KB
testcase_05 AC 28 ms
10,044 KB
testcase_06 AC 29 ms
10,044 KB
testcase_07 AC 29 ms
10,044 KB
testcase_08 AC 28 ms
10,044 KB
testcase_09 AC 29 ms
10,044 KB
testcase_10 AC 29 ms
10,044 KB
testcase_11 AC 28 ms
10,044 KB
testcase_12 AC 29 ms
10,044 KB
testcase_13 AC 29 ms
10,044 KB
testcase_14 AC 29 ms
10,044 KB
testcase_15 AC 28 ms
10,044 KB
testcase_16 AC 28 ms
10,044 KB
testcase_17 AC 29 ms
10,044 KB
testcase_18 AC 29 ms
10,044 KB
testcase_19 AC 29 ms
10,044 KB
testcase_20 AC 29 ms
10,044 KB
testcase_21 AC 29 ms
10,044 KB
testcase_22 AC 29 ms
10,044 KB
testcase_23 AC 82 ms
23,592 KB
testcase_24 AC 85 ms
23,592 KB
testcase_25 AC 84 ms
23,592 KB
testcase_26 AC 85 ms
23,592 KB
testcase_27 AC 29 ms
9,980 KB
testcase_28 AC 29 ms
10,044 KB
testcase_29 AC 29 ms
9,980 KB
testcase_30 AC 53 ms
11,836 KB
testcase_31 AC 52 ms
11,836 KB
testcase_32 AC 52 ms
11,836 KB
testcase_33 AC 53 ms
11,836 KB
testcase_34 AC 54 ms
11,836 KB
testcase_35 AC 60 ms
16,544 KB
testcase_36 AC 60 ms
17,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

'''
from math import gcd
from itertools import accumulate, combinations, permutations, product
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from operator import add, mul, sub, truediv, floordiv, mod

from decimal import *
getcontext().prec = 500

import string
ascii = string.ascii_lowercase
'''
from collections import deque
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = tuple(map(int, input().split()))

    a1 = [A[0]]
    for i in range(1, N):
        if a1[-1] != A[i]:
            a1.append(A[i])

    if len(a1) == 1:
        print(0)
        return

    a2 = deque(a1)
    for _ in [0] * len(a1):
        n = a2.popleft()
        if n != a2[-1]:
            a2.append(n)

    if len(set(a1)) != len(a2):
        print(-1)
    else:
        print(len(a1) - len(a2))


main()
0