結果

問題 No.710 チーム戦
ユーザー ngtkanangtkana
提出日時 2023-04-14 15:57:13
言語 Rust
(1.77.0)
結果
AC  
実行時間 20 ms / 3,000 ms
コード長 970 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 171,452 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 14:10:08
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 9 ms
6,944 KB
testcase_03 AC 10 ms
6,944 KB
testcase_04 AC 10 ms
6,940 KB
testcase_05 AC 9 ms
6,944 KB
testcase_06 AC 9 ms
6,940 KB
testcase_07 AC 10 ms
6,944 KB
testcase_08 AC 10 ms
6,944 KB
testcase_09 AC 10 ms
6,940 KB
testcase_10 AC 9 ms
6,940 KB
testcase_11 AC 9 ms
6,944 KB
testcase_12 AC 10 ms
6,944 KB
testcase_13 AC 10 ms
6,940 KB
testcase_14 AC 11 ms
6,940 KB
testcase_15 AC 10 ms
6,944 KB
testcase_16 AC 10 ms
6,944 KB
testcase_17 AC 9 ms
6,944 KB
testcase_18 AC 9 ms
6,944 KB
testcase_19 AC 10 ms
6,940 KB
testcase_20 AC 9 ms
6,944 KB
testcase_21 AC 10 ms
6,940 KB
testcase_22 AC 20 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 17 ms
6,940 KB
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::{convert::TryFrom, io::stdin, iter::repeat_with, usize::MAX};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lines().map(Result::unwrap);
    let n = stdin.next().unwrap().parse::<usize>().unwrap();
    let ab = repeat_with(|| {
        <[_; 2]>::try_from(
            stdin
                .next()
                .unwrap()
                .split_whitespace()
                .map(|x| x.parse::<usize>().unwrap())
                .collect::<Vec<_>>(),
        )
        .unwrap()
    })
    .take(n)
    .collect::<Vec<_>>();
    let lim = ab.iter().map(|&[x, _]| x).sum::<usize>() + 1;
    let mut dp = vec![MAX; lim];
    dp[0] = 0;
    for &[x, y] in &ab {
        let mut swp = dp.iter().map(|&x| x.saturating_add(y)).collect::<Vec<_>>();
        for i in 0..lim - x {
            swp[i + x] = swp[i + x].min(dp[i]);
        }
        dp = swp;
    }
    let ans = (0..lim).map(|i| i.max(dp[i])).min().unwrap();
    println!("{}", ans);
}
0