結果
問題 | No.2779 Don't make Pair |
ユーザー | 👑 KA37RI |
提出日時 | 2024-06-07 22:16:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 430 bytes |
コンパイル時間 | 135 ms |
コンパイル使用メモリ | 81,776 KB |
実行使用メモリ | 117,580 KB |
最終ジャッジ日時 | 2024-06-07 22:16:35 |
合計ジャッジ時間 | 3,781 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
54,132 KB |
testcase_01 | AC | 35 ms
53,440 KB |
testcase_02 | AC | 36 ms
54,428 KB |
testcase_03 | AC | 35 ms
54,100 KB |
testcase_04 | AC | 35 ms
55,528 KB |
testcase_05 | AC | 36 ms
53,808 KB |
testcase_06 | AC | 38 ms
54,736 KB |
testcase_07 | AC | 36 ms
54,508 KB |
testcase_08 | AC | 36 ms
54,312 KB |
testcase_09 | AC | 41 ms
62,620 KB |
testcase_10 | AC | 55 ms
76,820 KB |
testcase_11 | AC | 45 ms
65,232 KB |
testcase_12 | AC | 99 ms
103,552 KB |
testcase_13 | AC | 97 ms
103,604 KB |
testcase_14 | AC | 91 ms
91,780 KB |
testcase_15 | AC | 122 ms
108,240 KB |
testcase_16 | AC | 121 ms
105,100 KB |
testcase_17 | AC | 111 ms
106,868 KB |
testcase_18 | AC | 98 ms
99,420 KB |
testcase_19 | AC | 108 ms
101,640 KB |
testcase_20 | AC | 84 ms
90,580 KB |
testcase_21 | AC | 134 ms
110,420 KB |
testcase_22 | AC | 135 ms
110,392 KB |
testcase_23 | AC | 156 ms
117,580 KB |
testcase_24 | AC | 134 ms
110,416 KB |
testcase_25 | AC | 134 ms
110,272 KB |
testcase_26 | AC | 132 ms
110,164 KB |
testcase_27 | AC | 141 ms
110,296 KB |
testcase_28 | AC | 134 ms
110,016 KB |
ソースコード
from collections import Counter n = int(input()) a = [int(x) for x in input().split()] cnt = Counter(a) if any(cnt[x] >= 3 for x in a): print("0\n") exit() left = {} right = {} for i in range(n): right[a[i]] = i for i in range(n - 1, -1, -1): left[a[i]] = i p = 0 q = n - 1 for x in a: if left[x] == right[x]: continue p = max(left[x], p) q = min(right[x], q) r = range(p + 1, q + 1) print(len(r)) print(*r)