結果

問題 No.992 最長増加部分列の数え上げ
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-02-17 19:13:31
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 429 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 31,360 KB
最終ジャッジ日時 2024-04-16 03:54:53
合計ジャッジ時間 17,884 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
12,160 KB
testcase_01 AC 95 ms
12,032 KB
testcase_02 AC 94 ms
12,160 KB
testcase_03 WA -
testcase_04 AC 250 ms
18,944 KB
testcase_05 AC 213 ms
17,024 KB
testcase_06 AC 287 ms
20,480 KB
testcase_07 AC 232 ms
18,176 KB
testcase_08 AC 163 ms
15,232 KB
testcase_09 AC 241 ms
18,176 KB
testcase_10 AC 285 ms
20,480 KB
testcase_11 AC 340 ms
22,656 KB
testcase_12 AC 139 ms
13,824 KB
testcase_13 AC 230 ms
17,792 KB
testcase_14 AC 229 ms
18,048 KB
testcase_15 AC 139 ms
14,080 KB
testcase_16 AC 476 ms
28,672 KB
testcase_17 AC 163 ms
15,104 KB
testcase_18 AC 225 ms
17,792 KB
testcase_19 AC 335 ms
22,528 KB
testcase_20 AC 519 ms
30,080 KB
testcase_21 AC 516 ms
30,080 KB
testcase_22 AC 527 ms
30,080 KB
testcase_23 AC 517 ms
30,080 KB
testcase_24 AC 516 ms
29,952 KB
testcase_25 AC 516 ms
30,080 KB
testcase_26 AC 514 ms
29,952 KB
testcase_27 AC 515 ms
30,080 KB
testcase_28 AC 519 ms
30,080 KB
testcase_29 AC 516 ms
30,208 KB
testcase_30 AC 400 ms
30,848 KB
testcase_31 AC 397 ms
31,360 KB
testcase_32 AC 399 ms
31,360 KB
testcase_33 AC 398 ms
31,232 KB
testcase_34 AC 401 ms
30,848 KB
testcase_35 AC 402 ms
29,824 KB
testcase_36 AC 402 ms
29,824 KB
testcase_37 AC 402 ms
29,824 KB
testcase_38 AC 404 ms
29,952 KB
testcase_39 AC 401 ms
29,952 KB
testcase_40 AC 430 ms
30,464 KB
testcase_41 AC 433 ms
30,720 KB
testcase_42 AC 434 ms
30,592 KB
testcase_43 AC 430 ms
30,848 KB
testcase_44 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

INF = MOD = 10 ** 9 + 7
N = gets.to_i
A = gets.split.map(&:to_i)
dp1 = [[INF, -INF]]
dp2 = [[0, 1]]

A.each do |a|
  m = dp1.bsearch_index do |dpm|
    dpm[-1] >= a
  end || dp1.size
  
  j = dp1[m - 1].bsearch_index{|a_| a_ <= a }
  b = dp2[m - 1][-1] - dp2[m - 1][j - 1]
  
  if m < dp1.size
    dp1[m] << a
    dp2[m] << ((dp2[m][-1] + b) % MOD)
  else
    dp1 << [INF, a]
    dp2 << [0, (b % MOD)]
  end
end
puts dp2[-1][-1]
0