結果

問題 No.1946 ロッカーの問題
ユーザー atcoder8atcoder8
提出日時 2022-09-09 03:42:50
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 960 bytes
コンパイル時間 18,259 ms
コンパイル使用メモリ 399,120 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 20:52:22
合計ジャッジ時間 19,721 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let (n, _m) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse::<usize>().unwrap(),
            iter.next().unwrap().parse::<usize>().unwrap(),
        )
    };
    let aa = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse::<usize>().unwrap())
            .collect::<Vec<_>>()
    };

    let mut actual = vec![false; n + 1];
    for &a in aa.iter() {
        actual[a] = true;
    }

    let mut ans = 0_u32;
    let mut lockers = vec![false; n + 1];

    for i in 1..=n {
        if lockers[i] == actual[i] {
            ans += 1;
        } else {
            for j in (i..=n).step_by(i) {
                lockers[j] = !lockers[j];
            }
        }
    }

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