結果

問題 No.3066 Collecting Coins Speedrun 1
ユーザー srtry
提出日時 2025-04-27 15:42:14
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 457 bytes
コンパイル時間 12,092 ms
コンパイル使用メモリ 387,724 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-27 15:42:29
合計ジャッジ時間 14,153 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input!{
        n:usize,
        c:[isize;n],
    }

    let min_x:isize = *c.iter().min().unwrap();
    let max_x:isize = *c.iter().max().unwrap();
    
    let mut ans:usize = 2*(max_x - min_x) as usize;

    if min_x > 0 {
        ans += min_x as usize;
    } else if max_x < 0 {
        ans -= max_x as usize;
    }
    
    if c.len()==1 {
        ans = min_x.abs() as usize;
    }
    
    println!("{}", ans);
}
0