LC.P1921[消灭怪物的最大数量] 方法一:贪心+排序1234567891011121314class Solution { public int eliminateMaximum(int[] dist, int[] speed) { int n = dist.length; int[] times = new int[n]; for (int i = 0; i < n; ++i) times[i] = (dist[i] - 1) / speed[i]; Arrays.sort(times); for (int i = 0; i < n; ++i) { if (times[i] < i) { return i; } } return n; }} 时间复杂度:$O(nlogn)$ 空间复杂度:$O(n)$