結果

問題 No.1188 レベルX門松列
ユーザー simansiman
提出日時 2021-04-30 11:50:22
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 11,188 KB
実行使用メモリ 34,196 KB
最終ジャッジ日時 2023-09-25 12:38:26
合計ジャッジ時間 13,490 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 815 ms
34,180 KB
testcase_05 AC 81 ms
15,064 KB
testcase_06 AC 848 ms
33,556 KB
testcase_07 AC 812 ms
34,060 KB
testcase_08 AC 804 ms
33,876 KB
testcase_09 AC 78 ms
15,268 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 77 ms
15,016 KB
testcase_19 WA -
testcase_20 AC 77 ms
15,108 KB
testcase_21 AC 78 ms
14,992 KB
testcase_22 AC 77 ms
15,244 KB
testcase_23 AC 78 ms
15,292 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
B = A.map { |a| -a }

def lis(arr)
  len = arr.size
  dp = Array.new(len, Float::INFINITY)
  h1 = []

  len.times do |i|
    index = dp.bsearch_index { |x| x >= arr[i] }
    dp[index] = arr[i]
    h1.push(index)
  end

  dp2 = Array.new(len, Float::INFINITY)
  h2 = []

  len.times do |i|
    index = dp2.bsearch_index { |x| x >= arr[i] }
    dp2[index] = arr[i]
    h2.unshift(index)
  end

  [*0...len].map { |i| [h1[i], h2[i]].min }.max
end

puts [lis(A), lis(B)].max
0