結果

問題 No.1053 ゲーミング棒
コンテスト
ユーザー ttr
提出日時 2020-06-03 20:26:44
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 450 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 669 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 24,292 KB
最終ジャッジ日時 2026-05-20 00:36:25
合計ジャッジ時間 7,491 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = [int(a) for a in input().split()]

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

N = len(newA)
ans = 0
num = [0]*(max(newA)+1)
for i in range(N):
    if num[newA[i]] == 0:
        num[newA[i]] += 1
    elif newA[i-1] == newA[i]:
        num[newA[i]] += 1
    elif i == N-1 and newA[0] == newA[i] and N > 1:
        ans = 1
    else:
        ans = -1
        break
print(ans)
0