結果

問題 No.182 新規性の虜
ユーザー m0ntBL4Ncm0ntBL4Nc
提出日時 2019-10-10 16:14:23
言語 Rust
(1.77.0)
結果
MLE  
実行時間 -
コード長 1,397 bytes
コンパイル時間 2,538 ms
コンパイル使用メモリ 145,184 KB
実行使用メモリ 813,252 KB
最終ジャッジ日時 2023-08-13 16:47:11
合計ジャッジ時間 4,787 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
evil01.txt -- -
evil02.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let mut unique_number_count = 0;
    let number_of_integer: usize = getline().trim().parse().unwrap();
    
    let line = getline();
    let params: Vec<_> = line.trim().split(' ').collect();

    let mut v: Vec<i32> = Vec::new();

    for i in 0..number_of_integer {
        let number = params[i].parse().unwrap();
        v.push(number);
    }

    // vの中でmaxを探す
    let mut max = 0;

    for i in 0..number_of_integer {
        if v[i] > max {
            max = v[i];
        }
    }

    // 要素数maxの新しいvectorを作成する
    let mut number_appear_count_vector: Vec<i32> = Vec::new();
    for _ in 0..max {
        number_appear_count_vector.push(0);
    }

    let number_appear_count_vector_length = number_appear_count_vector.len();

    // vを走査し, vector[v[i]-1] += 1
    for i in 0..number_of_integer {
        let increment_index = (v[i] - 1) as usize; 
        number_appear_count_vector[increment_index] += 1;
    }

    // vectorのなかで vector[i] == 1 を見つけるたび, unique_number_count += 1
    for i in 0..number_appear_count_vector_length {
        if number_appear_count_vector[i] == 1 {
            unique_number_count += 1;
        }
    }

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