結果

問題 No.2741 Balanced Choice
ユーザー t33ft33f
提出日時 2024-04-21 12:13:16
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 667 bytes
コンパイル時間 6,323 ms
コンパイル使用メモリ 162,944 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 12:13:24
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
5,248 KB
testcase_01 AC 47 ms
5,376 KB
testcase_02 AC 49 ms
5,376 KB
testcase_03 AC 56 ms
5,376 KB
testcase_04 AC 57 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(non_snake_case)]
use proconio::{input};

fn main() {
    input!{
        n: usize, W: usize, D: usize,
        items: [(usize, usize, i32); n]
    }
    let mut value = vec![vec![i32::MIN; W + 1]; 2];
    value[0][0] = 0;
    value[1][0] = 0;
    for (t, w, v) in items {
        for x in (0..=(W - w)).rev() {
            value[t][x + w] = value[t][x + w].max(value[t][x] + v);
        }
    }

    let mut ans = 0;
    for x in 0..=W {
        for y in 0..=(W - x) {
            if x.abs_diff(y) <= D && value[0][x] >= 0 && value[1][y] >= 0 {
                ans = ans.max(value[0][x] + value[1][y]);
            }
        }
    }
    println!("{ans}");
}
0