結果

問題 No.1701 half price
ユーザー phspls
提出日時 2022-10-01 14:40:59
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 14,405 ms
コンパイル使用メモリ 377,732 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 19:49:51
合計ジャッジ時間 14,360 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut nw = String::new();
    std::io::stdin().read_line(&mut nw).ok();
    let nw: Vec<usize> = nw.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nw[0];
    let w = nw[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();

    let mut result = 0usize;
    for i in 0..1usize<<n {
        let targets = (0..n).filter(|&j| ((i >> j) & 1) == 1).collect::<Vec<usize>>();
        for halfs in 0..1usize<<targets.len() {
            let summary = (0..targets.len()).map(|j| if ((halfs >> j) & 1) == 1 { a[targets[j]] / 2 } else { a[targets[j]] }).sum::<usize>();
            if summary == w {
                result += 1;
                break;
            }
        }
    }
    println!("{}", result);
}
0