結果

問題 No.1199 お菓子配り-2
ユーザー StrorkisStrorkis
提出日時 2020-08-28 22:52:01
言語 Rust
(1.77.0)
結果
AC  
実行時間 67 ms / 1,000 ms
コード長 818 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 145,852 KB
実行使用メモリ 11,836 KB
最終ジャッジ日時 2023-08-08 22:53:44
合計ジャッジ時間 6,643 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 17 ms
4,484 KB
testcase_04 AC 43 ms
9,892 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 22 ms
5,708 KB
testcase_08 AC 28 ms
6,292 KB
testcase_09 AC 18 ms
4,960 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 14 ms
4,628 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 5 ms
4,384 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 27 ms
5,964 KB
testcase_17 AC 13 ms
4,380 KB
testcase_18 AC 29 ms
5,776 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 AC 51 ms
9,908 KB
testcase_21 AC 31 ms
6,160 KB
testcase_22 AC 18 ms
5,600 KB
testcase_23 AC 24 ms
5,600 KB
testcase_24 AC 35 ms
9,680 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 37 ms
7,380 KB
testcase_27 AC 29 ms
6,220 KB
testcase_28 AC 66 ms
11,804 KB
testcase_29 AC 66 ms
11,756 KB
testcase_30 AC 66 ms
11,656 KB
testcase_31 AC 66 ms
11,712 KB
testcase_32 AC 66 ms
11,780 KB
testcase_33 AC 66 ms
11,788 KB
testcase_34 AC 66 ms
11,756 KB
testcase_35 AC 66 ms
11,564 KB
testcase_36 AC 66 ms
11,728 KB
testcase_37 AC 67 ms
11,716 KB
testcase_38 AC 67 ms
11,680 KB
testcase_39 AC 66 ms
11,700 KB
testcase_40 AC 67 ms
11,772 KB
testcase_41 AC 66 ms
11,836 KB
testcase_42 AC 66 ms
11,636 KB
testcase_43 AC 66 ms
11,808 KB
testcase_44 AC 66 ms
11,728 KB
testcase_45 AC 66 ms
11,776 KB
testcase_46 AC 66 ms
11,820 KB
testcase_47 AC 66 ms
11,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::max;

fn main() {
    let (n, _m): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut a: Vec<Vec<i64>> = Vec::with_capacity(n);
    for _ in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        a.push(iter.map(|x| x.parse().unwrap()).collect())
    }

    let (mut odd, mut even) = (0, 0);
    for i in 0..n {
        let sum: i64 = a[i].iter().sum();
        odd = max(odd, even + sum);
        even = max(even, odd - sum);
    }

    println!("{}", odd);
}
0