結果
問題 |
No.1150 シュークリームゲーム(Easy)
|
ユーザー |
|
提出日時 | 2024-09-12 14:11:09 |
言語 | Rust (1.83.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,256 bytes |
コンパイル時間 | 16,338 ms |
コンパイル使用メモリ | 401,908 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-12 14:11:28 |
合計ジャッジ時間 | 16,871 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 WA * 11 RE * 6 |
ソースコード
use proconio::{input, marker::Usize1}; fn main() { input! { n:usize, s:Usize1, t:Usize1, a:[usize;n], } let ans = if n % 2 != 0 { let mut point = [0, 0]; for i in 0..n { match f(s, t, i, n) { 0 | 2 => point[0] += a[i], _ => point[1] += a[i], } // println!("{:?}",point); } point[0] as i64 - point[1] as i64 } else { let mut point = [0, 0]; let mut tmp = vec![]; for i in 0..n { match f(s, t, i, n) { 0 => point[0] += a[i], 1 => point[1] += a[i], _ => tmp.push(a[i]), } // println!("{:?}",point); } let (add_s, add_t) = if tmp.is_empty() { (0, 0) } else { (tmp[0].max(tmp[1]), tmp[0].min(tmp[1])) }; (point[0] + add_s) as i64 - (point[1] + add_t) as i64 }; println!("{}", ans); } fn f(s: usize, t: usize, p: usize, n: usize) -> usize { let d_s = s.abs_diff(p).min(s + n - p); let d_t = t.abs_diff(p).min(t + n - p); if d_s < d_t { 0 } else if d_t < d_s { 1 } else { 2 } }