結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
|
提出日時 | 2020-02-21 21:05:05 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 185 ms / 2,000 ms |
コード長 | 812 bytes |
コンパイル時間 | 12,850 ms |
コンパイル使用メモリ | 389,608 KB |
実行使用メモリ | 42,880 KB |
最終ジャッジ日時 | 2024-10-08 20:05:41 |
合計ジャッジ時間 | 15,019 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
fn main() {let mut nk = String::new();std::io::stdin().read_line(&mut nk).ok();let nk: Vec<usize> = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();let n = nk[0];let k = nk[1];let mut a: Vec<usize> = vec![];for _ in 0..n {let mut aa = String::new();std::io::stdin().read_line(&mut aa).ok();let aa: usize = aa.trim().parse().unwrap();a.push(aa);}let mut dp: Vec<Vec<bool>> = vec![vec![false; k+1]; n+1];dp[0][0] = true;for i in 0..n {for j in 0..=k {dp[i+1][j] |= dp[i][j];if a[i] <= j {dp[i+1][j] |= dp[i][j-a[i]];}}}println!("{}", dp[n].iter().enumerate().filter(|pair| *pair.1).map(|pair| pair.0).max().unwrap());}