結果
問題 | No.1701 half price |
ユーザー |
|
提出日時 | 2022-10-01 14:57:10 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 71 ms / 3,000 ms |
コード長 | 865 bytes |
コンパイル時間 | 13,238 ms |
コンパイル使用メモリ | 399,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 20:07:25 |
合計ジャッジ時間 | 14,839 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
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 1..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); }