結果

問題 No.1231 Make a Multiple of Ten
ユーザー StrorkisStrorkis
提出日時 2020-09-18 22:01:55
言語 Rust
(1.77.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 144,620 KB
実行使用メモリ 4,852 KB
最終ジャッジ日時 2023-09-05 18:19:44
合計ジャッジ時間 1,810 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 10 ms
4,376 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 19 ms
4,492 KB
testcase_13 AC 20 ms
4,852 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 20 ms
4,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

macro_rules! read_line_to_collection {
    ( $t:ty ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let iter = input.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect::<$t>()
    }};
}

use std::cmp::max;

fn main() {
    let _n = read_line_to_tuple!(usize);
    let a = read_line_to_collection!(Vec<i32>);

    let mut old = vec![std::i32::MIN; 10];
    old[0] = 0;
    for x in a.iter().map(|x| x % 10) {
        let mut new = old.clone();
        for i in 0..10 {
            let j = (i + x as usize) % 10;
            new[j] = max(new[j], old[i] + 1);
        }
        old = new;
    }
    println!("{}", old[0]);
}
0