結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-30 21:18:15 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 642 ms / 5,000 ms |
| コード長 | 788 bytes |
| コンパイル時間 | 13,189 ms |
| コンパイル使用メモリ | 401,108 KB |
| 実行使用メモリ | 8,604 KB |
| 最終ジャッジ日時 | 2025-03-09 20:22:55 |
| 合計ジャッジ時間 | 28,210 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
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);
}