結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2017-11-16 16:32:42 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 669 ms / 5,000 ms |
| コード長 | 617 bytes |
| コンパイル時間 | 872 ms |
| コンパイル使用メモリ | 105,848 KB |
| 実行使用メモリ | 7,736 KB |
| 最終ジャッジ日時 | 2024-06-12 22:34:57 |
| 合計ジャッジ時間 | 3,613 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.typecons;
int n; rd(n);
auto a=readln.split.to!(int[]);
auto rec=new int[](n);
fill(rec, 1);
sort(a);
size_t[int] pos;
foreach(i, e; a) pos[e]=i;
foreach(i, e0; a){
for(auto e=e0*2; e<=1_000_000; e+=e0){
if(e in pos){
auto j=pos[e];
rec[j]=max(rec[j], rec[i]+1);
}
}
}
writeln(reduce!(max)(rec));
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.length);
foreach(i, ref e; x){
e=l[i].to!(typeof(e));
}
}
ikd