結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tonyu0tonyu0
提出日時 2020-03-30 21:18:15
言語 Rust
(1.77.0)
結果
AC  
実行時間 604 ms / 5,000 ms
コード長 788 bytes
コンパイル時間 8,110 ms
コンパイル使用メモリ 158,592 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 01:01:41
合計ジャッジ時間 23,436 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 602 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 223 ms
6,940 KB
testcase_03 AC 433 ms
6,944 KB
testcase_04 AC 599 ms
6,940 KB
testcase_05 AC 604 ms
6,940 KB
testcase_06 AC 590 ms
6,944 KB
testcase_07 AC 599 ms
6,940 KB
testcase_08 AC 595 ms
6,940 KB
testcase_09 AC 593 ms
6,944 KB
testcase_10 AC 536 ms
6,940 KB
testcase_11 AC 567 ms
6,940 KB
testcase_12 AC 516 ms
6,944 KB
testcase_13 AC 541 ms
6,944 KB
testcase_14 AC 564 ms
6,944 KB
testcase_15 AC 500 ms
6,944 KB
testcase_16 AC 597 ms
6,944 KB
testcase_17 AC 594 ms
6,940 KB
testcase_18 AC 593 ms
6,944 KB
testcase_19 AC 588 ms
6,944 KB
testcase_20 AC 593 ms
6,944 KB
testcase_21 AC 591 ms
6,940 KB
testcase_22 AC 531 ms
6,944 KB
testcase_23 AC 559 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 12 ms
6,940 KB
testcase_26 AC 5 ms
6,940 KB
testcase_27 AC 4 ms
6,944 KB
testcase_28 AC 98 ms
6,940 KB
testcase_29 AC 51 ms
6,944 KB
testcase_30 AC 14 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn check(x: f64, k: usize, a: &Vec<f64>) -> bool {
    let mut res = 0;
    for i in 0..a.len() {
        res += (a[i] / x) as usize;
    }
    return res >= k;
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<f64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let k: usize = itr.next().unwrap().parse().unwrap();

    let mut l = 0.0;
    let mut r = 100000000000.0;
    for _ in 0..1000 {
        let mid = (l + r) / 2.0;
        if check(mid, k, &a) {
            l = mid;
        } else {
            r = mid;
        }
    }
    println!("{}", l);
}
0