結果

問題 No.2055 12x34...
ユーザー titiatitia
提出日時 2022-08-25 01:43:33
言語 Rust
(1.77.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 173,100 KB
実行使用メモリ 10,528 KB
最終ジャッジ日時 2024-04-20 14:05:45
合計ジャッジ時間 4,767 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 9 ms
5,376 KB
testcase_04 AC 13 ms
5,376 KB
testcase_05 AC 13 ms
5,376 KB
testcase_06 AC 12 ms
5,376 KB
testcase_07 AC 10 ms
5,376 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 15 ms
5,376 KB
testcase_10 AC 15 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 47 ms
5,812 KB
testcase_13 AC 83 ms
7,984 KB
testcase_14 AC 30 ms
5,376 KB
testcase_15 AC 31 ms
5,376 KB
testcase_16 AC 85 ms
8,292 KB
testcase_17 AC 30 ms
5,376 KB
testcase_18 AC 55 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 AC 72 ms
5,920 KB
testcase_23 AC 77 ms
7,964 KB
testcase_24 AC 78 ms
10,392 KB
testcase_25 AC 79 ms
8,732 KB
testcase_26 AC 78 ms
8,864 KB
testcase_27 AC 78 ms
10,528 KB
testcase_28 AC 80 ms
9,372 KB
testcase_29 AC 79 ms
10,064 KB
testcase_30 AC 79 ms
8,988 KB
testcase_31 AC 79 ms
8,728 KB
testcase_32 AC 79 ms
9,116 KB
testcase_33 AC 58 ms
5,376 KB
testcase_34 AC 59 ms
5,376 KB
testcase_35 AC 59 ms
5,376 KB
testcase_36 AC 59 ms
5,376 KB
testcase_37 AC 60 ms
5,376 KB
testcase_38 AC 58 ms
5,376 KB
testcase_39 AC 60 ms
5,376 KB
testcase_40 AC 60 ms
5,376 KB
testcase_41 AC 59 ms
5,376 KB
testcase_42 AC 60 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `A` should have a snake case name
  --> main.rs:10:9
   |
10 |     let A: Vec<i64> = {
   |         ^ help: convert the identifier to snake case: `a`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: variable `DP` should have a snake case name
  --> main.rs:21:13
   |
21 |     let mut DP: BTreeMap<i64, i64> = BTreeMap::new();
   |             ^^ help: convert the identifier to snake case: `dp`

warning: 2 warnings emitted

ソースコード

diff #

use std::collections::BTreeMap;

fn main() {
    let n: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let modx = 998244353;
    let mut ans=0;

    let mut DP: BTreeMap<i64, i64> = BTreeMap::new();

    for i in 0..n{
        let a=A[i];

        let mut x=0;

        if DP.contains_key(&(a-1)){
            x=DP[&(a-1)];
        }

        ans=(ans+x)%modx;

        if DP.contains_key(&(a)){
            DP.insert(a,(DP[&(a)]+x+1)%modx);
        }
        else{
            DP.insert(a,(x+1)%modx);
        }
    }

    println!("{}",ans);
}
0