結果

問題 No.710 チーム戦
ユーザー phsplsphspls
提出日時 2023-01-01 16:23:00
言語 Rust
(1.77.0)
結果
AC  
実行時間 93 ms / 3,000 ms
コード長 932 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 139,448 KB
実行使用メモリ 81,116 KB
最終ジャッジ日時 2023-08-17 23:05:07
合計ジャッジ時間 4,183 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,064 KB
testcase_01 AC 6 ms
6,644 KB
testcase_02 AC 87 ms
81,032 KB
testcase_03 AC 87 ms
81,092 KB
testcase_04 AC 89 ms
81,100 KB
testcase_05 AC 85 ms
81,100 KB
testcase_06 AC 87 ms
81,100 KB
testcase_07 AC 88 ms
81,080 KB
testcase_08 AC 88 ms
81,048 KB
testcase_09 AC 90 ms
81,072 KB
testcase_10 AC 85 ms
81,092 KB
testcase_11 AC 87 ms
81,096 KB
testcase_12 AC 87 ms
81,100 KB
testcase_13 AC 87 ms
81,116 KB
testcase_14 AC 86 ms
81,092 KB
testcase_15 AC 87 ms
81,084 KB
testcase_16 AC 87 ms
81,044 KB
testcase_17 AC 85 ms
81,044 KB
testcase_18 AC 88 ms
81,064 KB
testcase_19 AC 88 ms
81,100 KB
testcase_20 AC 86 ms
81,096 KB
testcase_21 AC 88 ms
81,092 KB
testcase_22 AC 79 ms
81,084 KB
testcase_23 AC 78 ms
81,096 KB
testcase_24 AC 93 ms
81,076 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 3 ms
4,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