結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-20 10:50:08 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,013 bytes |
| コンパイル時間 | 13,044 ms |
| コンパイル使用メモリ | 404,524 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-22 03:24:55 |
| 合計ジャッジ時間 | 16,338 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 13 |
コンパイルメッセージ
warning: unused variable: `n` --> src/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
ソースコード
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);
}