結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー fukafukatanifukafukatani
提出日時 2020-08-14 17:19:25
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,719 bytes
コンパイル時間 998 ms
コンパイル使用メモリ 159,104 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 18:49:14
合計ジャッジ時間 2,543 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_04 AC 0 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 RE -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 RE -
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 7 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 7 ms
5,376 KB
testcase_25 AC 7 ms
5,376 KB
testcase_26 AC 8 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 9 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 7 ms
5,376 KB
testcase_31 WA -
testcase_32 AC 7 ms
5,376 KB
testcase_33 AC 7 ms
5,376 KB
testcase_34 AC 8 ms
5,376 KB
testcase_35 WA -
testcase_36 AC 8 ms
5,376 KB
testcase_37 AC 7 ms
5,376 KB
testcase_38 AC 7 ms
5,376 KB
testcase_39 WA -
testcase_40 AC 8 ms
5,376 KB
testcase_41 AC 8 ms
5,376 KB
testcase_42 AC 6 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<usize>();
    let (s, t) = (v[0] - 1, v[1] - 1);
    let a = read_vec::<i64>();

    let mut span1 = (min(s, t) + 1..max(s, t)).map(|x| a[x]).collect::<Vec<_>>();
    let mut span2 = (max(s, t) + 1..n).map(|x| a[x]).collect::<Vec<_>>();
    span2.append(&mut (0..min(s, t)).map(|x| a[x]).collect::<Vec<_>>());

    if s > t {
        span1.reverse();
    } else {
        span2.reverse();
    }

    let mut s_score = a[s];
    s_score += span1.iter().take(span1.len() / 2).sum::<i64>();
    s_score += span2.iter().take(span2.len() / 2).sum::<i64>();
    if span1.len() % 2 == 1 && span2.len() % 2 == 1 {
        s_score += max(span1[span1.len() / 2], span2[span2.len() / 2]);
    } else if span1.len() % 2 == 1 {
        s_score += span1[span1.len() / 2];
    } else if span2.len() % 2 == 1 {
        s_score += span2[span1.len() / 2];
    }
    let all_score = a.iter().sum::<i64>();
    let t_score = all_score - s_score;
    println!("{}", s_score - t_score);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
0