結果

問題 No.1709 Indistinguishable by MEX
ユーザー minimumminimum
提出日時 2023-05-21 17:40:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 106,820 KB
最終ジャッジ日時 2024-06-01 12:40:47
合計ジャッジ時間 3,984 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,180 KB
testcase_01 AC 37 ms
52,936 KB
testcase_02 AC 38 ms
52,792 KB
testcase_03 AC 39 ms
52,680 KB
testcase_04 AC 38 ms
52,396 KB
testcase_05 AC 38 ms
53,164 KB
testcase_06 AC 38 ms
52,364 KB
testcase_07 AC 41 ms
52,888 KB
testcase_08 AC 78 ms
95,692 KB
testcase_09 AC 73 ms
90,788 KB
testcase_10 AC 69 ms
88,576 KB
testcase_11 AC 65 ms
84,328 KB
testcase_12 AC 63 ms
81,708 KB
testcase_13 AC 76 ms
95,816 KB
testcase_14 AC 73 ms
92,884 KB
testcase_15 AC 76 ms
95,456 KB
testcase_16 AC 89 ms
105,592 KB
testcase_17 AC 83 ms
100,640 KB
testcase_18 AC 87 ms
104,800 KB
testcase_19 AC 87 ms
104,728 KB
testcase_20 AC 87 ms
106,024 KB
testcase_21 AC 88 ms
106,820 KB
testcase_22 AC 86 ms
106,356 KB
testcase_23 AC 87 ms
105,676 KB
testcase_24 AC 87 ms
105,352 KB
testcase_25 AC 88 ms
105,548 KB
testcase_26 AC 38 ms
52,536 KB
testcase_27 AC 66 ms
85,848 KB
testcase_28 AC 63 ms
82,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

N = int(input())
P = list(map(int, input().split()))
pos = [-1] * N
for i in range(N):
    pos[P[i]] = i

l, r = pos[0], pos[0]

ans = 1

for i in range(1, N):
    if l < pos[i] < r:
        ans *= (r - l + 1 - i)
        ans %= MOD
    else:
        l = min(l, pos[i])
        r = max(r, pos[i])

print(ans)
0