結果

問題 No.1709 Indistinguishable by MEX
ユーザー roarisroaris
提出日時 2021-10-20 22:14:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 326 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,680 KB
実行使用メモリ 108,756 KB
最終ジャッジ日時 2023-10-20 11:10:52
合計ジャッジ時間 7,307 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,432 KB
testcase_01 AC 39 ms
53,432 KB
testcase_02 AC 38 ms
53,432 KB
testcase_03 AC 38 ms
53,432 KB
testcase_04 AC 38 ms
53,432 KB
testcase_05 AC 39 ms
53,432 KB
testcase_06 AC 39 ms
53,432 KB
testcase_07 AC 39 ms
53,432 KB
testcase_08 AC 272 ms
103,548 KB
testcase_09 AC 231 ms
102,372 KB
testcase_10 AC 229 ms
100,344 KB
testcase_11 AC 176 ms
94,292 KB
testcase_12 AC 165 ms
88,932 KB
testcase_13 AC 231 ms
104,152 KB
testcase_14 AC 218 ms
102,164 KB
testcase_15 AC 224 ms
104,096 KB
testcase_16 AC 256 ms
108,756 KB
testcase_17 AC 243 ms
106,128 KB
testcase_18 AC 326 ms
108,608 KB
testcase_19 AC 319 ms
108,608 KB
testcase_20 AC 323 ms
108,608 KB
testcase_21 AC 275 ms
108,608 KB
testcase_22 AC 267 ms
108,608 KB
testcase_23 AC 120 ms
108,608 KB
testcase_24 AC 120 ms
108,608 KB
testcase_25 AC 120 ms
108,608 KB
testcase_26 AC 39 ms
53,432 KB
testcase_27 AC 82 ms
93,800 KB
testcase_28 AC 73 ms
87,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
P = list(map(int, input().split()))
iP = [(i, P[i]) for i in range(N)]
iP.sort(key=lambda t: t[1])
l, r = iP[0][0], iP[0][0]
ans = 1
MOD = 998244353

for i in range(1, N):
    idx = iP[i][0]
    
    if idx<l:
        l = idx
    elif idx>r:
        r = idx
    else:
        ans *= r-l+1-i
        ans %= MOD

print(ans)
0