結果

問題 No.390 最長の数列
ユーザー tomerun
提出日時 2016-07-17 03:28:56
言語 Ruby
(3.4.1)
結果
AC  
実行時間 1,388 ms / 5,000 ms
コード長 201 bytes
コンパイル時間 53 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 28,032 KB
最終ジャッジ日時 2024-10-02 10:59:26
合計ジャッジ時間 6,915 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i
x = gets.split.map(&:to_i).sort
c = Array.new(1000001, -1)
x.each { |i| c[i] = 1 }

x.each { |i|
	(2*i).step(1000000, i) { |j|
		c[j] = [c[j], c[i] + 1].max if c[j] >= 0
	}
}

puts c.max
0