結果

問題 No.1709 Indistinguishable by MEX
ユーザー horitaka1999horitaka1999
提出日時 2021-11-07 00:34:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 124,800 KB
最終ジャッジ日時 2024-04-25 12:43:19
合計ジャッジ時間 5,313 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,632 KB
testcase_01 AC 49 ms
53,504 KB
testcase_02 AC 46 ms
53,376 KB
testcase_03 AC 46 ms
53,888 KB
testcase_04 AC 45 ms
53,376 KB
testcase_05 AC 47 ms
53,376 KB
testcase_06 AC 46 ms
53,248 KB
testcase_07 AC 46 ms
53,760 KB
testcase_08 AC 151 ms
119,808 KB
testcase_09 AC 116 ms
115,072 KB
testcase_10 AC 110 ms
110,080 KB
testcase_11 AC 102 ms
103,680 KB
testcase_12 AC 100 ms
100,352 KB
testcase_13 AC 131 ms
124,800 KB
testcase_14 AC 126 ms
119,680 KB
testcase_15 AC 131 ms
124,672 KB
testcase_16 AC 143 ms
109,952 KB
testcase_17 AC 137 ms
116,992 KB
testcase_18 AC 155 ms
109,940 KB
testcase_19 AC 153 ms
109,812 KB
testcase_20 AC 152 ms
109,936 KB
testcase_21 AC 148 ms
110,072 KB
testcase_22 AC 145 ms
109,816 KB
testcase_23 AC 137 ms
109,684 KB
testcase_24 AC 139 ms
109,816 KB
testcase_25 AC 138 ms
109,944 KB
testcase_26 AC 46 ms
53,760 KB
testcase_27 AC 100 ms
104,064 KB
testcase_28 AC 95 ms
99,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(input())                    
P = list(map(int,input().split()))
dic = defaultdict(int)
for i in range(N):
    dic[P[i]] = i
l = 0
r = 0
ans = 1
mod = 998244353
for x in range(N):
    if x == 0:
        l = dic[x]
        r = dic[x]
    else:
        index = dic[x]
        if l < index < r:
            ans *= (r-l+1-x)
            ans %= mod
        else:
            l = min(index,l)
            r = max(index,r)
print(ans)

0