結果

問題 No.1478 Simple Sugoroku
ユーザー StrorkisStrorkis
提出日時 2021-04-17 13:13:15
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 12,816 ms
コンパイル使用メモリ 401,036 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-03 20:16:24
合計ジャッジ時間 15,961 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let ref mut buf = Vec::new();
    std::io::Read::read_to_end(&mut std::io::stdin(), buf).ok();
    let mut iter = std::str::from_utf8(buf).unwrap().split_whitespace();

    macro_rules! scan {
        ([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::<Vec<_>>());
        (($($t:tt),*)) => (($(scan!($t)),*));
        ($t:ty) => (iter.next().unwrap().parse::<$t>().unwrap());
    }

    let (n, m) = scan!((f64, usize));
    let b = scan!([f64; m]);

    let first = b.first().unwrap();
    let last = b.last().unwrap();

    let mut res = f64::MAX;
    let mut sum = m as f64;
    for k in (0..m).rev() {
        if k == 0 {
            res = res.min(last - b[0]);
        } else {
            sum += last - b[k];
            res = res.min(sum / (m - k) as f64);
        }
    }

    let ans = (first - 1.0) + res + (n - last);
    println!("{}", ans);
}
0