結果

問題 No.2693 Sword
ユーザー well-definedwell-defined
提出日時 2024-09-17 07:31:13
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 944 bytes
コンパイル時間 14,553 ms
コンパイル使用メモリ 378,520 KB
実行使用メモリ 17,664 KB
最終ジャッジ日時 2024-09-17 07:31:29
合計ジャッジ時間 14,950 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 p = if p > 1000000000000000000 {0} 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] == 0 {
                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] > 1000000000000000000 { dp[i][j] = 0; }
            }
        }
    }
    //println!("{:?}", dp);
    if dp[k][n] == 0 {println!("{}", -1);}
    else {println!("{}", dp[k][n])};
    
}
0