結果

問題 No.1478 Simple Sugoroku
ユーザー phsplsphspls
提出日時 2022-11-03 21:13:32
言語 Rust
(1.77.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 4,669 ms
コンパイル使用メモリ 139,556 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 04:40:24
合計ジャッジ時間 6,436 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,500 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 6 ms
4,384 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 7 ms
4,376 KB
testcase_24 AC 7 ms
4,380 KB
testcase_25 AC 7 ms
4,380 KB
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 5 ms
4,380 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 6 ms
4,380 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 6 ms
4,380 KB
testcase_33 AC 6 ms
4,504 KB
testcase_34 AC 6 ms
4,380 KB
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 6 ms
4,376 KB
testcase_37 AC 6 ms
4,376 KB
testcase_38 AC 7 ms
4,380 KB
testcase_39 AC 6 ms
4,376 KB
testcase_40 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    let b: Vec<usize> = b.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    if m == 1 {
        println!("{}", n-1);
        return;
    }
    let result = (n - b[m-1] + b[0] - 1) as f64;
    let mut middle = (b[m-1] - b[0]) as f64;
    let mut summary = 0usize;
    for i in (1..m).rev() {
        summary += b[m-1] - b[i];
        let prob = (m-i) as f64 / m as f64;
        let exp = 1. / prob;
        let cost = exp + summary as f64 / (m-i) as f64;
        if middle > cost {
            middle = cost;
        }
    }
    println!("{}", result + middle);
}
0