結果

問題 No.1053 ゲーミング棒
ユーザー trineutron
提出日時 2020-05-16 11:04:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 20,808 KB
最終ジャッジ日時 2024-09-22 03:40:14
合計ジャッジ時間 3,052 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
s = [0] * n
s[a[0] - 1] = 1
for i in range(n - 1):
    if a[i + 1] != a[i]:
        s[a[i + 1] - 1] += 1
if a[0] == a[-1]:
    if n - s.count(0) - s.count(1) > 1 or n - s.count(0) - s.count(1) - s.count(2) > 0:
        print(-1)
    elif n - s.count(0) - s.count(1) == 1:
        print(1)
    else:
        print(0)
else:
    if n - s.count(0) - s.count(1) > 0:
        print(-1)
    else:
        print(0)
0