結果

問題 No.1709 Indistinguishable by MEX
ユーザー unti
提出日時 2021-05-28 00:06:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 364 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 29,756 KB
最終ジャッジ日時 2024-09-17 16:56:14
合計ジャッジ時間 5,423 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353 
n=int(input()) 
a = list(map(int, input().split())) 
place = [0 for i in range(n)]
for i in range(n) :
  place[a[i]] = i 
left = place[0] 
right = place[0]  
ans=1 
for i in range(n-1) :
  if place[i+1] < left :
    left = place[i+1] 
  elif place[i+1] > right :
    right = place[i+1] 
  else :
    ans=ans*(right-left-i) 
    ans%=mod

print(ans) 
0