結果
| 問題 | No.1053 ゲーミング棒 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-16 06:54:56 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 128 ms / 2,000 ms |
| コード長 | 902 bytes |
| 記録 | |
| コンパイル時間 | 314 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 28,680 KB |
| 最終ジャッジ日時 | 2026-04-10 00:34:13 |
| 合計ジャッジ時間 | 5,310 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
'''
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()