結果

問題 No.1053 ゲーミング棒
ユーザー stngstng
提出日時 2020-05-16 13:44:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 11,824 KB
実行使用メモリ 21,608 KB
最終ジャッジ日時 2023-10-22 06:06:44
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,112 KB
testcase_01 AC 28 ms
10,112 KB
testcase_02 AC 29 ms
10,112 KB
testcase_03 AC 28 ms
10,112 KB
testcase_04 AC 28 ms
10,112 KB
testcase_05 AC 28 ms
10,112 KB
testcase_06 AC 29 ms
10,112 KB
testcase_07 AC 28 ms
10,112 KB
testcase_08 AC 28 ms
10,112 KB
testcase_09 AC 28 ms
10,112 KB
testcase_10 AC 29 ms
10,112 KB
testcase_11 AC 28 ms
10,112 KB
testcase_12 AC 28 ms
10,112 KB
testcase_13 AC 28 ms
10,112 KB
testcase_14 AC 28 ms
10,112 KB
testcase_15 AC 29 ms
10,112 KB
testcase_16 AC 28 ms
10,112 KB
testcase_17 AC 28 ms
10,112 KB
testcase_18 AC 27 ms
10,112 KB
testcase_19 AC 28 ms
10,112 KB
testcase_20 AC 28 ms
10,112 KB
testcase_21 AC 27 ms
10,112 KB
testcase_22 AC 28 ms
10,112 KB
testcase_23 AC 120 ms
21,608 KB
testcase_24 AC 123 ms
21,608 KB
testcase_25 AC 130 ms
21,608 KB
testcase_26 AC 124 ms
21,608 KB
testcase_27 AC 29 ms
10,112 KB
testcase_28 AC 28 ms
10,112 KB
testcase_29 AC 29 ms
10,112 KB
testcase_30 AC 69 ms
11,908 KB
testcase_31 AC 71 ms
11,908 KB
testcase_32 AC 68 ms
11,908 KB
testcase_33 AC 64 ms
11,908 KB
testcase_34 AC 61 ms
11,908 KB
testcase_35 AC 76 ms
16,644 KB
testcase_36 AC 77 ms
17,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ai = [int(i) for i in input().split()]

fst = ai[0]

ima = ai[0]

li = [0]*(n+1)

flag = False

for i in range(n-1):
    #print(flag)
    if flag == True:
        if ima != ai[i+1]:
            print(-1)
            exit()
    if ima == ai[i+1]:
        continue
    #print(fst==ai[i+1])
    if fst == ai[i+1]:
        flag = True
    if li[ai[i+1]] == 0:
        li[ai[i+1]] = 1
        ima = ai[i+1]
    elif li[ai[i+1]] == 1:
        print(-1)
        exit()


if fst == ai[n-1]:
    print(min(1,sum(li)))
else:
    print(0)
0