結果

問題 No.1199 お菓子配り-2
ユーザー StrorkisStrorkis
提出日時 2020-08-28 22:52:01
言語 Rust
(1.77.0)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 818 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 153,344 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-26 15:04:34
合計ジャッジ時間 6,765 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 17 ms
5,376 KB
testcase_04 AC 44 ms
9,856 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 22 ms
5,760 KB
testcase_08 AC 29 ms
6,144 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 14 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 28 ms
6,016 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 29 ms
5,888 KB
testcase_19 AC 8 ms
5,376 KB
testcase_20 AC 52 ms
9,856 KB
testcase_21 AC 32 ms
6,144 KB
testcase_22 AC 19 ms
5,504 KB
testcase_23 AC 26 ms
5,632 KB
testcase_24 AC 36 ms
9,472 KB
testcase_25 AC 6 ms
5,376 KB
testcase_26 AC 37 ms
7,296 KB
testcase_27 AC 30 ms
6,016 KB
testcase_28 AC 69 ms
11,648 KB
testcase_29 AC 68 ms
11,520 KB
testcase_30 AC 69 ms
11,776 KB
testcase_31 AC 69 ms
11,648 KB
testcase_32 AC 68 ms
11,648 KB
testcase_33 AC 68 ms
11,648 KB
testcase_34 AC 69 ms
11,648 KB
testcase_35 AC 69 ms
11,648 KB
testcase_36 AC 69 ms
11,776 KB
testcase_37 AC 69 ms
11,648 KB
testcase_38 AC 70 ms
11,648 KB
testcase_39 AC 69 ms
11,776 KB
testcase_40 AC 70 ms
11,520 KB
testcase_41 AC 69 ms
11,776 KB
testcase_42 AC 69 ms
11,648 KB
testcase_43 AC 69 ms
11,648 KB
testcase_44 AC 69 ms
11,648 KB
testcase_45 AC 68 ms
11,776 KB
testcase_46 AC 69 ms
11,648 KB
testcase_47 AC 68 ms
11,776 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