結果

問題 No.2093 Shio Ramen
ユーザー phsplsphspls
提出日時 2022-10-09 19:02:13
言語 Rust
(1.77.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 855 bytes
コンパイル時間 1,028 ms
コンパイル使用メモリ 145,704 KB
実行使用メモリ 9,840 KB
最終ジャッジ日時 2023-09-05 22:23:37
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 8 ms
6,932 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 6 ms
5,576 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 11 ms
9,308 KB
testcase_19 AC 7 ms
6,336 KB
testcase_20 AC 5 ms
4,560 KB
testcase_21 AC 6 ms
5,320 KB
testcase_22 AC 5 ms
5,348 KB
testcase_23 AC 11 ms
9,800 KB
testcase_24 AC 12 ms
9,768 KB
testcase_25 AC 12 ms
9,832 KB
testcase_26 AC 11 ms
9,764 KB
testcase_27 AC 11 ms
9,796 KB
testcase_28 AC 11 ms
9,836 KB
testcase_29 AC 12 ms
9,840 KB
testcase_30 AC 12 ms
9,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut ni = String::new();
    std::io::stdin().read_line(&mut ni).ok();
    let ni: Vec<usize> = ni.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = ni[0];
    let t = ni[1];
    let items = (0..n).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
            (temp[0], temp[1])
        })
        .collect::<Vec<_>>();

    let mut dp = vec![vec![0usize; t+1]; n+1];
    for i in 0..n {
        let (s, a) = items[i];
        for j in 0..=t {
            dp[i+1][j] = dp[i+1][j].max(dp[i][j]);
            if j+s <= t {
                dp[i+1][j+s] = dp[i+1][j+s].max(dp[i][j] + a);
            }
        }
    }
    println!("{}", dp[n][t]);
}
0