結果
問題 | No.2317 Expression Menu |
ユーザー |
|
提出日時 | 2023-05-26 22:01:35 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 1,551 bytes |
コンパイル時間 | 11,327 ms |
コンパイル使用メモリ | 404,748 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 06:56:20 |
合計ジャッジ時間 | 15,270 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
fn main() { let (n, x, y): (usize, usize, usize) = { // 定数個の整数を受け取り, 定数個の変数に束縛する let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap() ) }; let mut a = Vec::new(); let mut b = Vec::new(); let mut c = Vec::new(); for _ in 0..n { let (p, q, r): (usize, usize, usize) = { // 定数個の整数を受け取り, 定数個の変数に束縛する let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap() ) }; a.push(p); b.push(q); c.push(r); } let mut dp = vec![vec![0; y + 1]; x + 1]; for i in 0..n { for j in (0..x+1).rev() { for k in (0..y+1).rev() { if a[i] <= j && b[i] <= k { dp[j][k] = dp[j][k].max(dp[j - a[i]][k - b[i]] + c[i]); } } } } let mut ans = 0; for i in 0..x+1 { for j in 0..y+1 { ans = ans.max(dp[i][j]); } } println!("{}", ans); }