結果

問題 No.1709 Indistinguishable by MEX
ユーザー とりゐとりゐ
提出日時 2022-05-28 16:57:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 81,668 KB
実行使用メモリ 107,020 KB
最終ジャッジ日時 2023-10-20 23:26:04
合計ジャッジ時間 4,984 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,456 KB
testcase_01 AC 38 ms
53,456 KB
testcase_02 AC 38 ms
53,456 KB
testcase_03 AC 38 ms
53,456 KB
testcase_04 AC 43 ms
53,456 KB
testcase_05 AC 38 ms
53,456 KB
testcase_06 AC 38 ms
53,456 KB
testcase_07 AC 38 ms
53,456 KB
testcase_08 AC 82 ms
96,668 KB
testcase_09 AC 73 ms
90,884 KB
testcase_10 AC 71 ms
88,428 KB
testcase_11 AC 66 ms
85,468 KB
testcase_12 AC 65 ms
83,632 KB
testcase_13 AC 79 ms
96,228 KB
testcase_14 AC 75 ms
93,248 KB
testcase_15 AC 78 ms
96,048 KB
testcase_16 AC 89 ms
105,912 KB
testcase_17 AC 85 ms
102,176 KB
testcase_18 AC 90 ms
106,136 KB
testcase_19 AC 91 ms
106,136 KB
testcase_20 AC 89 ms
106,136 KB
testcase_21 AC 88 ms
107,020 KB
testcase_22 AC 90 ms
106,568 KB
testcase_23 AC 90 ms
106,480 KB
testcase_24 AC 92 ms
106,480 KB
testcase_25 AC 87 ms
106,212 KB
testcase_26 AC 37 ms
53,468 KB
testcase_27 AC 66 ms
85,688 KB
testcase_28 AC 63 ms
83,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
p=list(map(int,input().split()))
idx=[0]*n
for i in range(n):
  idx[p[i]]=i

mod=998244353
ans=1
L,R=idx[0],idx[0]
size=0
for i in idx[1:]:
  if L<i<R:
    ans*=size
    ans%=mod
    size-=1
  else:
    if i<L:
      size+=L-i-1
      L=i
    else:
      size+=i-R-1
      R=i

print(ans)
0