結果
問題 | No.390 最長の数列 |
ユーザー |
![]() |
提出日時 | 2018-01-28 02:30:18 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 578 ms / 5,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 758 ms |
コンパイル使用メモリ | 109,576 KB |
実行使用メモリ | 15,344 KB |
最終ジャッジ日時 | 2024-06-12 23:40:35 |
合計ジャッジ時間 | 2,888 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.to!(int[]); } int calc(int[] xs) { auto dp = new int[xs.maxElement + 1]; bool[int] m; foreach (x; xs) m[x] = true; foreach (x; xs.sort!((a, b) => a > b)) { for (int i = x; i < dp.length; i += x) { if (i in m) { dp[x] = max(dp[x], dp[i] + 1); } } } return dp.maxElement; } void main() { readint; auto xs = readints; int ans = calc(xs); writeln(ans); }