結果

問題 No.1053 ゲーミング棒
ユーザー kohei2019kohei2019
提出日時 2022-07-18 00:14:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 86,648 KB
実行使用メモリ 119,692 KB
最終ジャッジ日時 2023-09-12 12:26:36
合計ジャッジ時間 6,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,324 KB
testcase_01 AC 73 ms
71,512 KB
testcase_02 AC 73 ms
71,244 KB
testcase_03 AC 72 ms
71,316 KB
testcase_04 AC 73 ms
71,640 KB
testcase_05 AC 72 ms
71,348 KB
testcase_06 AC 72 ms
71,208 KB
testcase_07 AC 72 ms
71,316 KB
testcase_08 AC 70 ms
71,488 KB
testcase_09 AC 72 ms
71,516 KB
testcase_10 AC 72 ms
71,348 KB
testcase_11 AC 71 ms
71,568 KB
testcase_12 AC 71 ms
71,192 KB
testcase_13 AC 72 ms
71,400 KB
testcase_14 AC 72 ms
71,472 KB
testcase_15 AC 71 ms
71,320 KB
testcase_16 AC 70 ms
71,412 KB
testcase_17 AC 72 ms
71,300 KB
testcase_18 AC 71 ms
71,344 KB
testcase_19 AC 71 ms
71,368 KB
testcase_20 AC 72 ms
71,416 KB
testcase_21 AC 73 ms
71,376 KB
testcase_22 AC 71 ms
71,336 KB
testcase_23 AC 108 ms
104,484 KB
testcase_24 AC 107 ms
104,784 KB
testcase_25 AC 125 ms
119,692 KB
testcase_26 AC 118 ms
114,116 KB
testcase_27 AC 70 ms
71,560 KB
testcase_28 AC 71 ms
71,324 KB
testcase_29 AC 69 ms
71,208 KB
testcase_30 AC 87 ms
88,880 KB
testcase_31 AC 95 ms
92,676 KB
testcase_32 AC 91 ms
89,808 KB
testcase_33 AC 96 ms
91,268 KB
testcase_34 AC 96 ms
92,092 KB
testcase_35 AC 96 ms
91,284 KB
testcase_36 AC 97 ms
91,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsA = list(map(int,input().split()))

used = set()
st = lsA[0]
f = True
for i in range(1,N):
    if st == lsA[i]:
        continue
    else:
        if lsA[i] in used:
            f = False
        used.add(st)
        st = lsA[i]
if f:
    print(0)
    exit()

en = lsA[-1]
ll = []
while lsA and lsA[-1] == en:
    ll.append(lsA.pop())
lsB = ll + lsA
used = set()
st = lsB[0]
for i in range(1,N):
    if st == lsB[i]:
        continue
    else:
        if lsB[i] in used:
            print(-1)
            exit()
        used.add(st)
        st = lsB[i]
print(1)
0