結果

問題 No.1709 Indistinguishable by MEX
ユーザー simansiman
提出日時 2023-09-14 17:49:52
言語 Ruby
(3.3.0)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 334 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 11,268 KB
実行使用メモリ 37,980 KB
最終ジャッジ日時 2023-09-14 17:50:02
合計ジャッジ時間 9,509 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,276 KB
testcase_01 AC 82 ms
15,120 KB
testcase_02 AC 86 ms
15,232 KB
testcase_03 AC 82 ms
15,140 KB
testcase_04 AC 81 ms
15,236 KB
testcase_05 AC 81 ms
15,288 KB
testcase_06 AC 81 ms
15,140 KB
testcase_07 AC 81 ms
15,220 KB
testcase_08 AC 305 ms
36,256 KB
testcase_09 AC 254 ms
33,220 KB
testcase_10 AC 241 ms
31,192 KB
testcase_11 AC 216 ms
27,832 KB
testcase_12 AC 204 ms
27,596 KB
testcase_13 AC 276 ms
34,812 KB
testcase_14 AC 256 ms
33,648 KB
testcase_15 AC 262 ms
34,616 KB
testcase_16 AC 316 ms
37,588 KB
testcase_17 AC 308 ms
36,728 KB
testcase_18 AC 341 ms
37,980 KB
testcase_19 AC 346 ms
37,800 KB
testcase_20 AC 349 ms
37,932 KB
testcase_21 AC 336 ms
37,908 KB
testcase_22 AC 334 ms
37,788 KB
testcase_23 AC 315 ms
37,744 KB
testcase_24 AC 322 ms
37,700 KB
testcase_25 AC 326 ms
37,808 KB
testcase_26 AC 84 ms
15,088 KB
testcase_27 AC 213 ms
28,060 KB
testcase_28 AC 199 ms
27,636 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
P = gets.split.map(&:to_i)
MOD = 998_244_353

pos = Hash.new
P.each_with_index do |v, i|
  pos[v] = i
end

l = Float::INFINITY
r = -Float::INFINITY
ans = 1

0.upto(N - 1) do |x|
  i = pos[x]

  if (l..r).cover?(i)
    ans *= (r - l - x + 1)
    ans %= MOD
  else
    l = i if l > i
    r = i if r < i
  end
end

puts ans
0