impl Solution { pubfncar_fleet(target: i32, position: Vec<i32>, speed: Vec<i32>) -> i32 { let n = position.len(); if n == 0 || n == 1 { return n asi32; } letmut src = vec![(0, 0.); n]; for i in0..n { src[i].0 = position[i]; src[i].1 = (target - position[i]) asf64 / speed[i] asf64; }
src.sort_by_key(|x| x.0); letmut ans = 0; for i in (1..n).rev() { if src[i].1 < src[i - 1].1 { ans += 1; continue; } src[i - 1] = src[i]; } return ans + 1; } }