結果
問題 |
No.1188 レベルX門松列
|
ユーザー |
![]() |
提出日時 | 2021-04-30 11:53:09 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 887 ms / 2,000 ms |
コード長 | 535 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 32,640 KB |
最終ジャッジ日時 | 2024-07-18 10:05:06 |
合計ジャッジ時間 | 13,063 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Syntax OK
ソースコード
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) arr2 = arr.reverse h2 = [] len.times do |i| index = dp2.bsearch_index { |x| x >= arr2[i] } dp2[index] = arr2[i] h2.unshift(index) end [*0...len].map { |i| [h1[i], h2[i]].min }.max end puts [lis(A), lis(B)].max