結果

問題 No.2693 Sword
ユーザー well-definedwell-defined
提出日時 2024-09-17 07:29:18
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 940 bytes
コンパイル時間 13,480 ms
コンパイル使用メモリ 379,096 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-09-17 07:29:33
合計ジャッジ時間 14,291 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,248 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 5 ms
6,144 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
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 AC 3 ms
5,376 KB
testcase_20 AC 6 ms
6,784 KB
testcase_21 AC 8 ms
8,832 KB
testcase_22 AC 4 ms
5,376 KB
testcase_23 AC 3 ms
5,376 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: 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 > 1000000000000000000 {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] > 1000000000000000000 { dp[i][j] = 0; }
            }
        }
    }
    //println!("{:?}", dp);
    if dp[k][n] == 0 {println!("{}", -1);}
    else {println!("{}", dp[k][n])};
    
}
0