結果

問題 No.390 最長の数列
ユーザー shi-moshi-mo
提出日時 2016-10-24 23:25:53
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,111 ms / 5,000 ms
コード長 295 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 28,800 KB
最終ジャッジ日時 2024-04-10 10:12:46
合計ジャッジ時間 4,884 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
12,288 KB
testcase_01 AC 81 ms
12,160 KB
testcase_02 AC 82 ms
12,288 KB
testcase_03 AC 79 ms
12,160 KB
testcase_04 AC 79 ms
12,288 KB
testcase_05 AC 161 ms
28,800 KB
testcase_06 AC 1,111 ms
28,672 KB
testcase_07 AC 80 ms
12,160 KB
testcase_08 AC 84 ms
20,096 KB
testcase_09 AC 142 ms
19,968 KB
testcase_10 AC 278 ms
28,672 KB
testcase_11 AC 287 ms
28,672 KB
testcase_12 AC 272 ms
28,672 KB
testcase_13 AC 357 ms
26,752 KB
testcase_14 AC 291 ms
20,736 KB
testcase_15 AC 77 ms
12,160 KB
testcase_16 AC 82 ms
19,968 KB
testcase_17 AC 94 ms
20,096 KB
testcase_18 AC 100 ms
20,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i
x = gets.chomp.split.map(&:to_i).sort

xmax = x.max
dp = Array.new(xmax + 1)
x.each do |xi|
  dp[xi] = 1
end

answer = 0
x.each do |xi|
  (xi*2).step(xmax, xi) do |j|
    next unless dp[j]

    dp[j] = [ dp[j], dp[xi]+1 ].max
  end
  answer = [ answer, dp[xi] ].max
end
puts answer
0