結果

問題 No.1692 Expectations
ユーザー Masaki KitaguchiMasaki Kitaguchi
提出日時 2022-01-08 18:00:07
言語 Rust
(1.77.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 1,819 ms
コンパイル使用メモリ 158,592 KB
実行使用メモリ 5,504 KB
最終ジャッジ日時 2024-04-26 19:24:46
合計ジャッジ時間 3,723 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 11 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 22 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 12 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 25 ms
5,444 KB
testcase_20 AC 7 ms
5,376 KB
testcase_21 AC 7 ms
5,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut buf = String::new();
    let mut input = {
        use std::io::Read;
        std::io::stdin().read_to_string(&mut buf).unwrap();
        buf.split_whitespace()
    };

    let n: usize = input.next().unwrap().parse().unwrap();
    let m: usize = input.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n)
        .map(|_| input.next().unwrap().parse().unwrap())
        .collect();

    a.sort();

    let mut count = vec![0; m];
    for i in 0..n {
        let j = a[i] - 1;
        count[j] += 1
    }

    let max = count.iter().filter(|&&x| x >= 1).count();

    let min = if m - n == 0 && max == 1 { 1 } else { 0 };

    println!("{} {}", max, min);
}
0