結果
問題 | No.1199 お菓子配り-2 |
ユーザー | uw_yu1rabbit |
提出日時 | 2020-08-28 22:05:22 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,027 bytes |
コンパイル時間 | 12,600 ms |
コンパイル使用メモリ | 404,988 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 03:31:27 |
合計ジャッジ時間 | 19,739 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,820 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
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 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
コンパイルメッセージ
warning: unused import: `std::collections::*` --> src/main.rs:2:5 | 2 | use std::collections::*; | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused variable: `j` --> src/main.rs:22:13 | 22 | for j in 0..m { | ^ help: if this is intentional, prefix it with an underscore: `_j` | = note: `#[warn(unused_variables)]` on by default warning: variable does not need to be mutable --> src/main.rs:23:17 | 23 | let mut l:i64 = read(); | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
ソースコード
use std::cmp::*; use std::collections::*; use std::io::*; use std::str::FromStr; fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } fn main(){ let n:usize = read(); let m:usize = read(); let mut a:Vec<i64> = vec![0;n]; for i in 0..n{ let mut rec:i64 = 0; for j in 0..m { let mut l:i64 = read(); rec += l; } a[i] = rec; } let mut dp:Vec<Vec<i64>> = vec![vec![0;2];n]; dp[0][0] = a[0]; for i in 1..n{ dp[i][0] = max(dp[i - 1][1],0) + a[i]; dp[i][1] = dp[i - 1][0] - a[i]; } let mut ans:i64 = 0; for i in 0..n{ for j in 0..2{ ans = max(ans,dp[i][j]); } } println!("{}",ans); }