結果
問題 | No.999 てん vs. ほむ |
ユーザー |
![]() |
提出日時 | 2022-12-20 20:19:45 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 10,351 ms |
コンパイル使用メモリ | 377,912 KB |
実行使用メモリ | 7,808 KB |
最終ジャッジ日時 | 2024-11-18 02:07:56 |
合計ジャッジ時間 | 12,337 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
fn main() { let mut xx = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok(); let xx: Vec<i64> = xx.split_whitespace().skip(1).flat_map(str::parse).collect(); let n = xx.len() / 2; let diff: Vec<i64> = xx.chunks(2).map(|x| x[0] - x[1]).collect(); let mut left = vec![0; n + 1]; let mut right = vec![0; n + 1]; left[1] = diff[0]; right[n - 1] = -diff[n - 1]; for i in 2..=n { left[i] = left[i - 1] + diff[i - 1]; right[n - i] = right[n - i + 1] - diff[n - i]; } let answer = (0..=n).map(|i| left[i] + right[i]).max().unwrap(); println!("{answer}"); }