結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 6 ms
7,680 KB
testcase_17 AC 7 ms
8,448 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 1 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 8 ms
9,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main () {
    input! {
        n: usize,
        p: u64,
        k: usize,
    }
    let mut s: Vec<(usize,u64)> = Vec::new();
    s.push((1,0));
    for _ in 0..n { 
        input! {
            t: usize,
            b: u64,
        }
        s.push((t, b));
    }
    let p = if p > (1<<18) {0} else {p};
    let mut dp: Vec<Vec<u64>> = 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] > (1<<18) { dp[i][j] = 0; }
            }
        }
    }
    //println!("{:?}", dp);
    if dp[k][n] == 0 {println!("{}", -1);}
    else {println!("{}", dp[k][n])};
    
}
0