結果

問題 No.1053 ゲーミング棒
コンテスト
ユーザー convexineq
提出日時 2020-05-15 21:35:05
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 492 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 679 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 24,216 KB
最終ジャッジ日時 2026-04-07 19:02:00
合計ジャッジ時間 11,070 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 

n,*a = list(map(int,read().split()))

res = [0]*(n+3)
now = 10**6

two = 0
for i in a:
    if i != now:
        res[i] += 1        
        if res[i]==2: two += 1
        elif res[i] == 3: two = 100
        now = i

if two >= 2:
    print(-1)
elif two == 1:
    if a[0] == a[-1] and res[a[0]] == 2:
        print(1)
    else:
        print(-1)
elif two==0:
    print(0)

#print(res[:5],two)


0