結果

問題 No.2433 Min Increasing Sequence
ユーザー tomeruntomerun
提出日時 2023-08-18 23:12:45
言語 Crystal
(1.11.2)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 22,267 ms
コンパイル使用メモリ 253,204 KB
実行使用メモリ 19,004 KB
最終ジャッジ日時 2023-08-18 23:13:10
合計ジャッジ時間 22,634 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,412 KB
testcase_01 AC 3 ms
4,416 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 34 ms
19,004 KB
testcase_05 AC 18 ms
11,404 KB
testcase_06 AC 28 ms
17,184 KB
testcase_07 AC 20 ms
13,568 KB
testcase_08 AC 31 ms
18,156 KB
testcase_09 AC 24 ms
14,036 KB
testcase_10 AC 13 ms
9,124 KB
testcase_11 AC 20 ms
11,368 KB
testcase_12 AC 13 ms
9,468 KB
testcase_13 AC 11 ms
8,064 KB
testcase_14 AC 23 ms
13,824 KB
testcase_15 AC 10 ms
8,256 KB
testcase_16 AC 14 ms
9,552 KB
testcase_17 AC 10 ms
7,876 KB
testcase_18 AC 32 ms
18,140 KB
testcase_19 AC 31 ms
18,264 KB
testcase_20 AC 4 ms
5,168 KB
testcase_21 AC 30 ms
17,048 KB
testcase_22 AC 31 ms
18,156 KB
testcase_23 AC 29 ms
17,304 KB
testcase_24 AC 31 ms
18,336 KB
testcase_25 AC 30 ms
17,412 KB
testcase_26 AC 23 ms
14,140 KB
testcase_27 AC 29 ms
17,576 KB
testcase_28 AC 25 ms
14,468 KB
testcase_29 AC 8 ms
6,996 KB
testcase_30 AC 8 ms
6,900 KB
testcase_31 AC 7 ms
6,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353i64
n = read_line.to_i
a = read_line.split.map(&.to_i)
cnt = Array.new(n + 1, 0i64)
sum = Array.new(n + 1, 0i64)
cnt[n] = 1
sum[n] = 1
min = a[-1]
min_pos = n - 1
(n - 1).downto(0) do |i|
  if a[i] <= min
    min = a[i]
    min_pos = i
  end
  cnt[i] = sum[min_pos + 1]
  sum[i] = (sum[i + 1] + cnt[i]) % MOD
end
puts cnt[0]
0