結果

問題 No.390 最長の数列
ユーザー WagiHOHWagiHOH
提出日時 2016-07-10 17:34:32
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 1,223 ms / 5,000 ms
コード長 559 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 94,028 KB
実行使用メモリ 8,708 KB
最終ジャッジ日時 2023-09-02 21:20:31
合計ジャッジ時間 5,354 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
4,368 KB
testcase_01 AC 12 ms
4,372 KB
testcase_02 AC 22 ms
4,368 KB
testcase_03 AC 13 ms
4,368 KB
testcase_04 AC 23 ms
4,372 KB
testcase_05 AC 57 ms
8,160 KB
testcase_06 AC 1,223 ms
8,052 KB
testcase_07 AC 9 ms
4,368 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 12 ms
4,372 KB
testcase_10 AC 189 ms
8,144 KB
testcase_11 AC 206 ms
8,332 KB
testcase_12 AC 192 ms
8,016 KB
testcase_13 AC 255 ms
7,624 KB
testcase_14 AC 700 ms
8,708 KB
testcase_15 AC 1 ms
4,368 KB
testcase_16 AC 1 ms
4,368 KB
testcase_17 AC 6 ms
4,368 KB
testcase_18 AC 11 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.range;

void main()
{
    enum MAX_N = 10 ^^ 5, MAX_X = 10 ^^ 6 + 1;
    int[MAX_N] buf;
    immutable n = readln.chomp.to!int;
    readln.splitter.map!(to!int).copy(buf[]);
    auto set = buf[0..n].sort();
    int[int] cache;
    foreach_reverse (x; set) {
        cache[x] = iota(2 * x, MAX_X, x)
                    .filter!(i => set.contains(i))
                    .map!(i => cache[i])
                    .fold!max(0) + 1;
    }
    writeln(cache.values.fold!max);
}
0