結果

問題 No.99 ジャンピング駒
ユーザー phsplsphspls
提出日時 2020-02-23 13:05:42
言語 Rust
(1.77.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 491 bytes
コンパイル時間 1,012 ms
コンパイル使用メモリ 163,760 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 08:32:59
合計ジャッジ時間 1,554 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,248 KB
testcase_01 AC 8 ms
5,376 KB
testcase_02 AC 8 ms
5,376 KB
testcase_03 AC 9 ms
5,376 KB
testcase_04 AC 8 ms
5,376 KB
testcase_05 AC 8 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::{min, max};

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut x = String::new();
    std::io::stdin().read_line(&mut x).ok();
    let x: Vec<isize> = x.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let odd: usize = x.iter().filter(|i| i.abs() as usize % 2 == 1).count();
    let even: usize = n - odd;
    println!("{}", max(odd, even) - min(odd, even));
}
0