結果

問題 No.844 split game
ユーザー phsplsphspls
提出日時 2022-12-14 11:20:36
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,254 bytes
コンパイル時間 1,106 ms
コンパイル使用メモリ 175,588 KB
実行使用メモリ 9,776 KB
最終ジャッジ日時 2024-04-25 15:44:46
合計ジャッジ時間 3,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
6,816 KB
testcase_01 AC 21 ms
7,624 KB
testcase_02 AC 40 ms
6,940 KB
testcase_03 AC 33 ms
7,748 KB
testcase_04 AC 16 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 53 ms
9,692 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 51 ms
9,776 KB
testcase_19 AC 50 ms
9,648 KB
testcase_20 AC 51 ms
9,652 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 4 ms
6,940 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 5 ms
6,940 KB
testcase_34 AC 3 ms
6,940 KB
testcase_35 AC 6 ms
6,940 KB
testcase_36 AC 4 ms
6,940 KB
testcase_37 AC 8 ms
6,944 KB
testcase_38 AC 10 ms
6,940 KB
testcase_39 AC 20 ms
6,940 KB
testcase_40 AC 11 ms
6,944 KB
testcase_41 AC 1 ms
6,940 KB
testcase_42 AC 1 ms
6,940 KB
testcase_43 AC 1 ms
6,944 KB
testcase_44 AC 1 ms
6,940 KB
testcase_45 AC 1 ms
6,944 KB
testcase_46 AC 1 ms
6,940 KB
testcase_47 AC 1 ms
6,944 KB
testcase_48 WA -
testcase_49 AC 1 ms
6,940 KB
testcase_50 AC 1 ms
6,940 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1 ms
6,944 KB
testcase_54 AC 1 ms
6,944 KB
testcase_55 AC 1 ms
6,940 KB
testcase_56 AC 1 ms
6,944 KB
testcase_57 AC 1 ms
6,940 KB
testcase_58 AC 1 ms
6,944 KB
testcase_59 AC 1 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const INF: isize = 1isize << 60;

fn main() {
    let mut nma = String::new();
    std::io::stdin().read_line(&mut nma).ok();
    let nma: Vec<usize> = nma.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nma[0];
    let m = nma[1];
    let a = nma[2] as isize;
    let mut lines = (0..m).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
            (temp[0]-1, temp[1], temp[2] as isize)
        })
        .collect::<Vec<_>>();

    lines.sort();
    let mut dp = vec![vec![-INF; 2]; n+1];
    for i in 0..=n { dp[i][0] = 0; }
    dp[0][1] = 0;
    let mut lidx = 0usize;
    for &(l, r, p) in lines.iter() {
        while lidx < l {
            if lidx > 0 {
                dp[lidx][0] = dp[lidx][0].max(dp[lidx-1][0]).max(dp[lidx-1][1]);
            }
            lidx += 1;
        }
        let lcost = if l == 0 { 0 } else { a };
        let rcost = if r == n { 0 } else { a };
        dp[r][1] = dp[r][1].max(dp[l][0] + p - lcost - rcost).max(dp[l][1] + p - rcost);
    }
    println!("{}", dp.iter().map(|v| v.iter().max().unwrap()).max().unwrap());
}
0