結果

問題 No.582 キャンディー・ボックス3
ユーザー phspls
提出日時 2020-06-20 15:59:38
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 11,591 ms
コンパイル使用メモリ 377,752 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-03 17:23:41
合計ジャッジ時間 12,568 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    let summary: usize = c.iter().map(|i| *i).sum();
    let has2: Vec<usize> = c.iter().map(|i| *i).filter(|&i| i > 1).collect();
    if has2.len() == 0 {
        if summary % 2 == 0 {
            println!("B");
        } else {
            println!("A");
        }
    } else if has2.len() > 1 || has2[0] > 2 {
        println!("B");
    } else {
        if summary % 2 == 0 {
            println!("B");
        } else {
            println!("A");
        }
    }
}
0