結果

問題 No.2779 Don't make Pair
ユーザー manoto43manoto43
提出日時 2024-06-07 22:44:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 108,160 KB
最終ジャッジ日時 2024-06-07 22:44:12
合計ジャッジ時間 4,106 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,992 KB
testcase_01 AC 39 ms
53,376 KB
testcase_02 AC 39 ms
53,376 KB
testcase_03 AC 37 ms
53,248 KB
testcase_04 AC 39 ms
53,120 KB
testcase_05 AC 40 ms
53,376 KB
testcase_06 AC 39 ms
53,376 KB
testcase_07 AC 38 ms
53,248 KB
testcase_08 AC 39 ms
53,760 KB
testcase_09 AC 53 ms
65,024 KB
testcase_10 AC 77 ms
84,736 KB
testcase_11 AC 59 ms
68,096 KB
testcase_12 AC 119 ms
98,176 KB
testcase_13 AC 103 ms
94,464 KB
testcase_14 AC 98 ms
89,984 KB
testcase_15 AC 124 ms
103,680 KB
testcase_16 AC 123 ms
103,296 KB
testcase_17 AC 114 ms
94,336 KB
testcase_18 AC 107 ms
97,152 KB
testcase_19 AC 116 ms
101,120 KB
testcase_20 AC 93 ms
87,296 KB
testcase_21 AC 159 ms
107,648 KB
testcase_22 AC 136 ms
107,904 KB
testcase_23 AC 164 ms
107,928 KB
testcase_24 AC 136 ms
107,776 KB
testcase_25 AC 143 ms
107,904 KB
testcase_26 AC 138 ms
108,160 KB
testcase_27 AC 142 ms
107,904 KB
testcase_28 AC 134 ms
107,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter,defaultdict

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    l,r = set(),set()
    d_l,d_r = defaultdict(int),Counter(A)

    for k in d_r.keys():
        if d_r[k] > 1:
            r.add(k)
    
    ans = []

    for i,a in enumerate(A[:-1]):
        d_l[a] += 1
        if d_l[a] > 1:
            l.add(a)
        
        d_r[a] -= 1
        if d_r[a] <= 1 and a in r:
            r.remove(a)
        
        if not(l or r):
            ans.append(i+1)
    
    print(len(ans))
    print(*ans)







if __name__ == "__main__":
    main()
0