結果

問題 No.1709 Indistinguishable by MEX
ユーザー rin204rin204
提出日時 2022-01-25 02:46:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 105,984 KB
最終ジャッジ日時 2024-05-08 23:47:55
合計ジャッジ時間 4,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 43 ms
51,840 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 AC 39 ms
51,840 KB
testcase_04 AC 39 ms
52,352 KB
testcase_05 AC 39 ms
51,584 KB
testcase_06 AC 40 ms
51,840 KB
testcase_07 AC 40 ms
51,968 KB
testcase_08 AC 92 ms
96,128 KB
testcase_09 AC 76 ms
90,368 KB
testcase_10 AC 73 ms
87,936 KB
testcase_11 AC 68 ms
83,968 KB
testcase_12 AC 67 ms
81,792 KB
testcase_13 AC 80 ms
95,616 KB
testcase_14 AC 78 ms
92,032 KB
testcase_15 AC 83 ms
95,488 KB
testcase_16 AC 91 ms
104,960 KB
testcase_17 AC 87 ms
100,736 KB
testcase_18 AC 92 ms
104,704 KB
testcase_19 AC 92 ms
105,088 KB
testcase_20 AC 92 ms
105,216 KB
testcase_21 AC 91 ms
105,600 KB
testcase_22 AC 91 ms
105,984 KB
testcase_23 AC 94 ms
105,856 KB
testcase_24 AC 93 ms
105,728 KB
testcase_25 AC 97 ms
105,600 KB
testcase_26 AC 41 ms
51,992 KB
testcase_27 AC 67 ms
84,096 KB
testcase_28 AC 65 ms
82,176 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