結果
問題 | No.1199 お菓子配り-2 |
ユーザー | akakimidori |
提出日時 | 2020-08-28 21:50:56 |
言語 | Rust (1.72.1) |
結果 |
AC
|
実行時間 | 63 ms / 1,000 ms |
コード長 | 2,227 bytes |
コンパイル時間 | 2,011 ms |
コンパイル使用メモリ | 152,448 KB |
実行使用メモリ | 26,208 KB |
最終ジャッジ日時 | 2023-08-08 22:34:06 |
合計ジャッジ時間 | 7,805 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 18 ms
7,836 KB |
testcase_04 | AC | 39 ms
15,108 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 3 ms
4,380 KB |
testcase_07 | AC | 20 ms
8,340 KB |
testcase_08 | AC | 27 ms
13,260 KB |
testcase_09 | AC | 17 ms
7,836 KB |
testcase_10 | AC | 5 ms
4,376 KB |
testcase_11 | AC | 13 ms
5,496 KB |
testcase_12 | AC | 12 ms
5,488 KB |
testcase_13 | AC | 5 ms
4,376 KB |
testcase_14 | AC | 5 ms
4,380 KB |
testcase_15 | AC | 4 ms
4,376 KB |
testcase_16 | AC | 27 ms
13,204 KB |
testcase_17 | AC | 12 ms
5,412 KB |
testcase_18 | AC | 28 ms
13,532 KB |
testcase_19 | AC | 8 ms
4,660 KB |
testcase_20 | AC | 45 ms
16,172 KB |
testcase_21 | AC | 30 ms
13,784 KB |
testcase_22 | AC | 17 ms
7,784 KB |
testcase_23 | AC | 23 ms
8,572 KB |
testcase_24 | AC | 31 ms
13,724 KB |
testcase_25 | AC | 5 ms
4,376 KB |
testcase_26 | AC | 35 ms
14,320 KB |
testcase_27 | AC | 29 ms
13,524 KB |
testcase_28 | AC | 61 ms
26,144 KB |
testcase_29 | AC | 60 ms
26,192 KB |
testcase_30 | AC | 61 ms
26,192 KB |
testcase_31 | AC | 62 ms
26,100 KB |
testcase_32 | AC | 61 ms
26,200 KB |
testcase_33 | AC | 62 ms
26,188 KB |
testcase_34 | AC | 63 ms
26,112 KB |
testcase_35 | AC | 62 ms
26,136 KB |
testcase_36 | AC | 63 ms
26,140 KB |
testcase_37 | AC | 62 ms
26,208 KB |
testcase_38 | AC | 60 ms
26,184 KB |
testcase_39 | AC | 63 ms
26,180 KB |
testcase_40 | AC | 62 ms
26,188 KB |
testcase_41 | AC | 61 ms
26,200 KB |
testcase_42 | AC | 62 ms
26,144 KB |
testcase_43 | AC | 62 ms
26,144 KB |
testcase_44 | AC | 62 ms
26,140 KB |
testcase_45 | AC | 62 ms
26,188 KB |
testcase_46 | AC | 62 ms
26,188 KB |
testcase_47 | AC | 63 ms
26,100 KB |
ソースコード
// ---------- begin chmin, chmax ---------- trait ChangeMinMax { fn chmin(&mut self, x: Self) -> bool; fn chmax(&mut self, x: Self) -> bool; } impl<T: PartialOrd> ChangeMinMax for T { fn chmin(&mut self, x: Self) -> bool { *self > x && { *self = x; true } } fn chmax(&mut self, x: Self) -> bool { *self < x && { *self = x; true } } } // ---------- end chmin, chmax ---------- //https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::<Vec<u8>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // fn run() { input! { h: usize, w: usize, a: [[i64; w]; h], } let mut b = vec![]; for a in a { b.push(a.iter().sum::<i64>()); } let mut dp = (0, std::i64::MIN / 2); for b in b { let (x, y) = dp; dp.0.chmax(y - b); dp.1.chmax(x + b); } let ans = std::cmp::max(dp.0, dp.1); println!("{}", ans); } fn main() { run(); }