結果

問題 No.1053 ゲーミング棒
ユーザー takakin
提出日時 2020-06-09 22:03:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 24,092 KB
最終ジャッジ日時 2025-01-02 22:25:30
合計ジャッジ時間 4,136 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
if n<=2:
  print(0)
elif len(set(A))==1:
  print(0)
else:
  chk=0
  while True:
    if A[-1]==A[0]:
      A.pop()
      chk=1
    else:
      break
  prev=0
  C=set()
  for i,a in enumerate(A):
    if a==prev:
      continue
    else:
      if a in C:
        print(-1)
        break
      else:
        C.add(a)
        prev=a
  else:
    print(chk)

0