結果

問題 No.844 split game
ユーザー phsplsphspls
提出日時 2022-12-07 12:18:04
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,210 bytes
コンパイル時間 1,658 ms
コンパイル使用メモリ 176,272 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-21 21:05:34
合計ジャッジ時間 5,634 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
5,248 KB
testcase_01 AC 17 ms
7,680 KB
testcase_02 AC 27 ms
6,272 KB
testcase_03 AC 24 ms
7,680 KB
testcase_04 AC 12 ms
5,376 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 35 ms
9,728 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 35 ms
9,728 KB
testcase_19 WA -
testcase_20 AC 36 ms
9,728 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
5,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 10 ms
5,376 KB
testcase_39 AC 20 ms
5,376 KB
testcase_40 AC 11 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 0 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 WA -
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 1 ms
5,376 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
  --> main.rs:11:9
   |
11 |     let mut lines = (0..m).map(|_| {
   |         ----^^^^^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: 1 warning emitted

ソースコード

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<_>>();

    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 {
            dp[lidx+1][0] = dp[lidx+1][0].max(dp[lidx][0]).max(dp[lidx][1]);
            lidx += 1;
        }
        let leftcost = if l == 0 { 0 } else { a };
        let rightcost = if r == n { 0 } else { a };
        dp[r][1] = dp[r][1].max(dp[l][0] - leftcost - rightcost + p).max(dp[l][1] - rightcost + p);
    }
    println!("{}", dp.iter().map(|v| v.iter().max().unwrap()).max().unwrap());
}
0