結果

問題 No.99 ジャンピング駒
ユーザー nak3nak3
提出日時 2017-11-22 21:19:32
言語 Rust
(1.77.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 641 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 151,864 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-17 14:28:24
合計ジャッジ時間 1,658 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: u64 = read().unwrap();
    let mut o = 0;
    let mut e = 0;
    for _ in 0..n {
        let tmp: i64 = read().unwrap();
        if tmp % 2 == 0 {
            e = e + 1;
        } else {
            o = o + 1;
        }
    }
    let ans = e - o;
    if ans < 0 {
        println!("{}", ans * (-1));
        return;
    }
    println!("{}", ans);
}
0