結果

問題 No.2218 Multiple LIS
ユーザー koba-e964koba-e964
提出日時 2023-02-17 21:49:12
言語 Rust
(1.77.0)
結果
AC  
実行時間 115 ms / 3,000 ms
コード長 1,429 bytes
コンパイル時間 3,375 ms
コンパイル使用メモリ 156,300 KB
実行使用メモリ 20,056 KB
最終ジャッジ日時 2023-09-26 19:06:03
合計ジャッジ時間 7,984 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
18,892 KB
testcase_01 AC 85 ms
18,832 KB
testcase_02 AC 93 ms
18,904 KB
testcase_03 AC 92 ms
18,908 KB
testcase_04 AC 87 ms
18,932 KB
testcase_05 AC 90 ms
18,868 KB
testcase_06 AC 89 ms
18,892 KB
testcase_07 AC 94 ms
18,924 KB
testcase_08 AC 88 ms
18,908 KB
testcase_09 AC 87 ms
18,912 KB
testcase_10 AC 87 ms
18,816 KB
testcase_11 AC 88 ms
18,912 KB
testcase_12 AC 88 ms
18,852 KB
testcase_13 AC 92 ms
18,880 KB
testcase_14 AC 90 ms
18,904 KB
testcase_15 AC 90 ms
18,916 KB
testcase_16 AC 88 ms
18,908 KB
testcase_17 AC 90 ms
18,908 KB
testcase_18 AC 88 ms
18,868 KB
testcase_19 AC 88 ms
18,852 KB
testcase_20 AC 88 ms
18,908 KB
testcase_21 AC 86 ms
19,252 KB
testcase_22 AC 100 ms
19,524 KB
testcase_23 AC 105 ms
19,764 KB
testcase_24 AC 90 ms
19,260 KB
testcase_25 AC 100 ms
19,744 KB
testcase_26 AC 109 ms
20,020 KB
testcase_27 AC 107 ms
19,996 KB
testcase_28 AC 115 ms
20,024 KB
testcase_29 AC 108 ms
19,980 KB
testcase_30 AC 108 ms
20,056 KB
testcase_31 AC 105 ms
19,680 KB
testcase_32 AC 108 ms
19,724 KB
testcase_33 AC 97 ms
19,716 KB
testcase_34 AC 103 ms
19,676 KB
testcase_35 AC 102 ms
19,740 KB
testcase_36 AC 103 ms
19,632 KB
testcase_37 AC 111 ms
19,616 KB
testcase_38 AC 87 ms
18,904 KB
testcase_39 AC 83 ms
18,916 KB
testcase_40 AC 101 ms
19,656 KB
testcase_41 AC 98 ms
19,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::*;
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr,) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    const W: usize = 100_001;
    let mut divs = vec![vec![]; W];
    for i in 1..W {
        for j in 1..=(W - 1) / i {
            divs[i * j].push(i);
        }
    }
    let mut dp = vec![0; W];
    for i in 0..n {
        let mut ma = 0;
        for &d in &divs[a[i]] {
            ma = max(ma, dp[d]);
        }
        dp[a[i]] = ma + 1;
    }
    println!("{}", dp.iter().max().unwrap());
}
0