結果

問題 No.1512 作文
ユーザー StrorkisStrorkis
提出日時 2021-05-21 22:53:45
言語 Rust
(1.77.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,104 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 172,776 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 16:21:14
合計ジャッジ時間 2,096 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 0 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 20 ms
6,944 KB
testcase_05 AC 18 ms
6,944 KB
testcase_06 AC 19 ms
6,944 KB
testcase_07 AC 18 ms
6,944 KB
testcase_08 AC 18 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 0 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 0 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 1 ms
6,944 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 0 ms
6,940 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 1 ms
6,940 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 1 ms
6,944 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 AC 31 ms
6,944 KB
testcase_41 AC 10 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let ref mut buf = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), buf).ok();
    let mut iter = buf.split_whitespace();

    macro_rules! scan {
        ([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::<Vec<_>>());
        (($($t:tt),*)) => (($(scan!($t)),*));
        (Usize1) => (scan!(usize) - 1);
        (Bytes) => (scan!(String).into_bytes());
        ($t:ty) => (iter.next().unwrap().parse::<$t>().unwrap());
    }

    let n = scan!(usize);
    let mut s = {
        (0..n)
            .map(|_| scan!(Bytes))
            .filter(|s| s.windows(2).all(|s| s[0] <= s[1]))
            .map(|s| (*s.first().unwrap(), *s.last().unwrap(), s.len()))
            .collect::<Vec<_>>()
    };
    s.sort();

    let mut dp = vec![0; 26];
    let mut p = 0;
    for (s, e, l) in s {
        let (s, e) = ((s - b'a') as usize, (e - b'a') as usize);
        while s != p {
            dp[p + 1] = dp[p + 1].max(dp[p]);
            p += 1;
        }
        dp[e] = dp[e].max(dp[s] + l);
    }

    let ans = dp.iter().max().unwrap();
    println!("{}", ans);
}
0