結果

問題 No.2693 Sword
ユーザー well-definedwell-defined
提出日時 2024-09-17 07:38:51
言語 Rust
(1.77.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 11,955 ms
コンパイル使用メモリ 401,820 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-09-17 07:39:05
合計ジャッジ時間 13,285 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,812 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 10 ms
10,240 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 7 ms
8,448 KB
testcase_16 AC 12 ms
13,568 KB
testcase_17 AC 14 ms
15,104 KB
testcase_18 AC 6 ms
6,940 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 11 ms
11,648 KB
testcase_21 AC 16 ms
15,872 KB
testcase_22 AC 7 ms
7,936 KB
testcase_23 AC 5 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 0 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 16 ms
17,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main () {
    input! {
        n: usize,
        p: u128,
        k: usize,
    }
    let mut s: Vec<(usize,u128)> = Vec::new();
    s.push((1,0));
    for _ in 0..n { 
        input! {
            t: usize,
            b: u128,
        }
        s.push((t, b));
    }
    let bound: u128 = 1000000000000000000;
    let p = if p > bound {bound+1} else {p};
    let mut dp: Vec<Vec<u128>> = vec![vec![p;n+1];n+1];
    for i in 1..dp.len() {
        for j in i..dp[i].len() {
            if dp[i][j-1] == bound+1 {
                dp[i][j] = dp[i][j-1];
            }
            else {
                dp[i][j] = dp[i][j-1].max(
                    if s[j].0 == 1 { dp[i-1][j-1]+s[j].1 }
                    else {dp[i-1][j-1]*2}
                );
                if dp[i][j] > bound { dp[i][j] = bound+1; }
            }
        }
    }
    //println!("{:?}", dp);
    if dp[k][n] == bound+1 {println!("{}", -1);}
    else {println!("{}", dp[k][n])};
    
}
0