結果

問題 No.1709 Indistinguishable by MEX
ユーザー 👑 rin204rin204
提出日時 2022-01-25 02:46:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 108,996 KB
最終ジャッジ日時 2023-08-21 18:09:42
合計ジャッジ時間 4,656 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,456 KB
testcase_01 AC 71 ms
71,280 KB
testcase_02 AC 70 ms
71,464 KB
testcase_03 AC 70 ms
71,312 KB
testcase_04 AC 71 ms
71,444 KB
testcase_05 AC 70 ms
71,340 KB
testcase_06 AC 71 ms
71,392 KB
testcase_07 AC 71 ms
71,288 KB
testcase_08 AC 109 ms
101,712 KB
testcase_09 AC 102 ms
97,836 KB
testcase_10 AC 101 ms
95,716 KB
testcase_11 AC 96 ms
92,908 KB
testcase_12 AC 94 ms
91,044 KB
testcase_13 AC 110 ms
101,176 KB
testcase_14 AC 103 ms
98,200 KB
testcase_15 AC 107 ms
100,948 KB
testcase_16 AC 116 ms
108,828 KB
testcase_17 AC 111 ms
104,932 KB
testcase_18 AC 116 ms
108,748 KB
testcase_19 AC 117 ms
108,456 KB
testcase_20 AC 117 ms
108,800 KB
testcase_21 AC 119 ms
108,976 KB
testcase_22 AC 118 ms
108,996 KB
testcase_23 AC 117 ms
108,872 KB
testcase_24 AC 118 ms
108,700 KB
testcase_25 AC 118 ms
108,684 KB
testcase_26 AC 70 ms
71,436 KB
testcase_27 AC 94 ms
93,040 KB
testcase_28 AC 92 ms
91,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n = int(input())
P = list(map(int, input().split()))
pos = [-1] * n
for i, p in enumerate(P):
    pos[p] = i
    
ans = 1
l = n
r = -1
for i, p in enumerate(pos):
    if l <= p <= r:
        ans *= r - l - i + 1
        ans %= MOD
    else:
        l = min(l, p)
        r = max(r, p)
print(ans)
0