leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1921.cpp (422B)


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