結果

問題 No.992 最長増加部分列の数え上げ
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-02-17 19:44:35
言語 Ruby
(3.3.0)
結果
AC  
実行時間 656 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 43,008 KB
最終ジャッジ日時 2024-04-16 03:55:26
合計ジャッジ時間 19,323 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
12,160 KB
testcase_01 AC 93 ms
12,160 KB
testcase_02 AC 94 ms
12,288 KB
testcase_03 AC 96 ms
12,288 KB
testcase_04 AC 283 ms
22,144 KB
testcase_05 AC 226 ms
18,944 KB
testcase_06 AC 320 ms
24,064 KB
testcase_07 AC 254 ms
20,864 KB
testcase_08 AC 181 ms
15,872 KB
testcase_09 AC 271 ms
21,760 KB
testcase_10 AC 325 ms
24,448 KB
testcase_11 AC 395 ms
28,160 KB
testcase_12 AC 141 ms
14,336 KB
testcase_13 AC 242 ms
19,456 KB
testcase_14 AC 248 ms
20,352 KB
testcase_15 AC 146 ms
14,720 KB
testcase_16 AC 579 ms
37,248 KB
testcase_17 AC 173 ms
16,128 KB
testcase_18 AC 253 ms
20,352 KB
testcase_19 AC 388 ms
27,904 KB
testcase_20 AC 642 ms
42,112 KB
testcase_21 AC 635 ms
42,880 KB
testcase_22 AC 645 ms
42,496 KB
testcase_23 AC 656 ms
42,752 KB
testcase_24 AC 639 ms
42,624 KB
testcase_25 AC 642 ms
41,984 KB
testcase_26 AC 648 ms
41,856 KB
testcase_27 AC 640 ms
43,008 KB
testcase_28 AC 638 ms
42,112 KB
testcase_29 AC 628 ms
41,856 KB
testcase_30 AC 396 ms
31,104 KB
testcase_31 AC 395 ms
31,360 KB
testcase_32 AC 394 ms
30,720 KB
testcase_33 AC 391 ms
30,976 KB
testcase_34 AC 393 ms
31,616 KB
testcase_35 AC 394 ms
30,208 KB
testcase_36 AC 396 ms
30,080 KB
testcase_37 AC 398 ms
30,080 KB
testcase_38 AC 402 ms
30,080 KB
testcase_39 AC 403 ms
29,952 KB
testcase_40 AC 425 ms
30,464 KB
testcase_41 AC 425 ms
31,104 KB
testcase_42 AC 429 ms
30,592 KB
testcase_43 AC 427 ms
30,592 KB
testcase_44 AC 432 ms
30,720 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

INF = 10 ** 10
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
  else
    dp1 << [INF, a]
    dp2 << [0, b]
  end
end
puts dp2[-1][-1] % MOD
0