結果

問題 No.1972 Modulo Set
ユーザー phsplsphspls
提出日時 2022-09-20 10:50:08
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 149,472 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2023-08-23 19:31:45
合計ジャッジ時間 4,504 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 22 ms
4,660 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 18 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 16 ms
4,376 KB
testcase_23 AC 32 ms
6,084 KB
testcase_24 AC 13 ms
4,380 KB
testcase_25 AC 19 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 33 ms
6,160 KB
testcase_28 AC 12 ms
4,380 KB
testcase_29 AC 18 ms
4,380 KB
testcase_30 AC 26 ms
5,212 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 22 ms
5,036 KB
testcase_33 AC 38 ms
6,784 KB
testcase_34 AC 38 ms
6,528 KB
testcase_35 AC 38 ms
6,676 KB
testcase_36 AC 38 ms
6,748 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
 --> Main.rs:8:9
  |
8 |     let n = nm[0];
  |         ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::collections::BTreeMap;


fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    if m == 1 {
        println!("1");
        return;
    }
    let mut mapping = BTreeMap::new();
    for &v in a.iter() {
        *mapping.entry(v%m).or_insert(0usize) += 1;
    }
    let mut result = 0usize;
    for (&key, cnt) in mapping.iter() {
        let other = m - key;
        if other == key {
            result += 1;
            continue;
        }
        if other < key && mapping.contains_key(&other) {
            continue;
        }
        let othercnt = *mapping.get(&other).unwrap_or(&0usize);
        result += cnt.max(&othercnt);
    }
    println!("{}", result);
}
0