1 2 3 4 5 6 7 8 9 10 11 12 13 14
| class Solution { public: int eliminateMaximum(vector<int>& dist, vector<int>& speed) { int n = dist.size(); vector<int> t(n); for (int i = 0; i < n; ++i) { t[i] = (dist[i] + speed[i] - 1) / speed[i]; } sort(t.begin(), t.end()); for (int i = 0; i < n; ++i) if (t[i] <= i) return i; return n; } };
|