結果
問題 | No.390 最長の数列 |
ユーザー | ikd |
提出日時 | 2017-11-14 18:44:38 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 608 ms / 5,000 ms |
コード長 | 617 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 93,636 KB |
実行使用メモリ | 9,676 KB |
最終ジャッジ日時 | 2023-09-03 16:54:41 |
合計ジャッジ時間 | 3,205 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
4,376 KB |
testcase_01 | AC | 14 ms
4,380 KB |
testcase_02 | AC | 29 ms
4,376 KB |
testcase_03 | AC | 24 ms
4,376 KB |
testcase_04 | AC | 31 ms
4,376 KB |
testcase_05 | AC | 45 ms
8,180 KB |
testcase_06 | AC | 508 ms
9,676 KB |
testcase_07 | AC | 13 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 13 ms
4,376 KB |
testcase_10 | AC | 94 ms
8,084 KB |
testcase_11 | AC | 107 ms
8,532 KB |
testcase_12 | AC | 98 ms
8,196 KB |
testcase_13 | AC | 136 ms
7,500 KB |
testcase_14 | AC | 608 ms
8,136 KB |
testcase_15 | AC | 1 ms
4,380 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 4 ms
4,376 KB |
testcase_18 | AC | 6 ms
4,376 KB |
ソースコード
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, e; a){ for(auto t=2; e*t<=1_000_000; t++){ if(e*t in pos){ auto j=pos[e*t]; 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)); } }