結果

問題 No.710 チーム戦
ユーザー phsplsphspls
提出日時 2023-01-01 16:23:00
言語 Rust
(1.77.0)
結果
AC  
実行時間 90 ms / 3,000 ms
コード長 932 bytes
コンパイル時間 13,829 ms
コンパイル使用メモリ 379,724 KB
実行使用メモリ 81,152 KB
最終ジャッジ日時 2024-05-05 05:52:37
合計ジャッジ時間 14,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 5 ms
6,528 KB
testcase_02 AC 84 ms
81,152 KB
testcase_03 AC 85 ms
81,024 KB
testcase_04 AC 84 ms
81,024 KB
testcase_05 AC 82 ms
81,024 KB
testcase_06 AC 85 ms
81,024 KB
testcase_07 AC 86 ms
81,024 KB
testcase_08 AC 84 ms
81,024 KB
testcase_09 AC 84 ms
80,896 KB
testcase_10 AC 85 ms
81,024 KB
testcase_11 AC 85 ms
80,896 KB
testcase_12 AC 86 ms
81,024 KB
testcase_13 AC 85 ms
81,024 KB
testcase_14 AC 84 ms
81,024 KB
testcase_15 AC 84 ms
81,024 KB
testcase_16 AC 87 ms
80,896 KB
testcase_17 AC 83 ms
81,024 KB
testcase_18 AC 90 ms
81,024 KB
testcase_19 AC 89 ms
81,024 KB
testcase_20 AC 85 ms
81,024 KB
testcase_21 AC 85 ms
80,896 KB
testcase_22 AC 80 ms
81,024 KB
testcase_23 AC 79 ms
80,896 KB
testcase_24 AC 89 ms
81,024 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const INF: usize = 1usize << 60;
const LIMIT: usize = 1e5 as usize;

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    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![INF; LIMIT+1]; n+1];
    dp[0][0] = 0;
    for i in 0..n {
        let (a, b) = items[i];
        for j in 0..=LIMIT {
            if dp[i][j] == INF { continue; }
            dp[i+1][j+a] = dp[i+1][j+a].min(dp[i][j]);
            dp[i+1][j] = dp[i+1][j].min(dp[i][j] + b);
        }
    }
    println!("{}", (0..=LIMIT).filter(|&i| dp[n][i] < INF).map(|i| dp[n][i].max(i)).min().unwrap());
}
0