結果

問題 No.2433 Min Increasing Sequence
ユーザー tomeruntomerun
提出日時 2023-08-18 23:12:45
言語 Crystal
(1.11.2)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 12,929 ms
コンパイル使用メモリ 295,416 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-05-06 05:47:31
合計ジャッジ時間 15,086 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 31 ms
19,200 KB
testcase_05 AC 15 ms
10,008 KB
testcase_06 AC 25 ms
15,232 KB
testcase_07 AC 17 ms
12,032 KB
testcase_08 AC 27 ms
17,152 KB
testcase_09 AC 22 ms
14,720 KB
testcase_10 AC 12 ms
8,320 KB
testcase_11 AC 17 ms
9,984 KB
testcase_12 AC 10 ms
7,424 KB
testcase_13 AC 8 ms
6,272 KB
testcase_14 AC 21 ms
14,336 KB
testcase_15 AC 8 ms
6,272 KB
testcase_16 AC 11 ms
8,448 KB
testcase_17 AC 8 ms
6,144 KB
testcase_18 AC 27 ms
17,152 KB
testcase_19 AC 26 ms
17,220 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 25 ms
15,488 KB
testcase_22 AC 28 ms
17,200 KB
testcase_23 AC 25 ms
15,332 KB
testcase_24 AC 29 ms
17,376 KB
testcase_25 AC 26 ms
16,896 KB
testcase_26 AC 22 ms
14,208 KB
testcase_27 AC 25 ms
15,488 KB
testcase_28 AC 23 ms
14,464 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 AC 6 ms
5,376 KB
testcase_31 AC 4 ms
5,376 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