<p>You are playing a video game where you are defending your city from a group of <code>n</code> monsters. You are given a <strong>0-indexed</strong> integer array <code>dist</code> of size <code>n</code>, where <code>dist[i]</code> is the <strong>initial distance</strong> in kilometers of the <code>i<sup>th</sup></code> monster from the city.</p>

<p>The monsters walk toward the city at a <strong>constant</strong> speed. The speed of each monster is given to you in an integer array <code>speed</code> of size <code>n</code>, where <code>speed[i]</code> is the speed of the <code>i<sup>th</sup></code> monster in kilometers per minute.</p>

<p>You have a weapon that, once fully charged, can eliminate a <strong>single</strong> monster. However, the weapon takes <strong>one minute</strong> to charge. The weapon is fully charged at the very start.</p>

<p>You lose when any monster reaches your city. If a monster reaches the city at the exact moment the weapon is fully charged, it counts as a <strong>loss</strong>, and the game ends before you can use your weapon.</p>

<p>Return <em>the <strong>maximum</strong> number of monsters that you can eliminate before you lose, or </em><code>n</code><em> if you can eliminate all the monsters before they reach the city.</em></p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> dist = [1,3,4], speed = [1,1,1]
<strong>Output:</strong> 3
<strong>Explanation:</strong>
In the beginning, the distances of the monsters are [1,3,4]. You eliminate the first monster.
After a minute, the distances of the monsters are [X,2,3]. You eliminate the second monster.
After a minute, the distances of the monsters are [X,X,2]. You eliminate the third monster.
All 3 monsters can be eliminated.</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> dist = [1,1,2,3], speed = [1,1,1,1]
<strong>Output:</strong> 1
<strong>Explanation:</strong>
In the beginning, the distances of the monsters are [1,1,2,3]. You eliminate the first monster.
After a minute, the distances of the monsters are [X,0,1,2], so you lose.
You can only eliminate 1 monster.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> dist = [3,2,4], speed = [5,3,2]
<strong>Output:</strong> 1
<strong>Explanation:</strong>
In the beginning, the distances of the monsters are [3,2,4]. You eliminate the first monster.
After a minute, the distances of the monsters are [X,0,2], so you lose.
You can only eliminate 1 monster.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == dist.length == speed.length</code></li>
	<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= dist[i], speed[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution {
public:
/*
Premium qs of lc of goofav on gfg: 
q1. https://www.geeksforgeeks.org/assign-campus-bikes-to-workers/
method1: sort triplets and greedily assign to the workers tc: O(n*m * log(n*m))
method2: bucket sort : vector< vector<triplets> > buckets i.e. for dis =d ,we have vector of triplets having separation=d
tc: (maxManhattan dits + n*m)
https://www.geeksforgeeks.org/assign-campus-bikes-to-workers-ii/
Apply DP : use bitmask to keep track of alloted bikes
*/
    int eliminateMaximum(vector<int>& dist, vector<int>& speed) {
        int n=dist.size();
        vector<double>reach_times;

        for(int i=0;i<n;i++){
            double time= ((dist[i]*1.0)/speed[i]) ;
            reach_times.push_back(time);
        }
     sort(reach_times.begin(),reach_times.end());

  int  mons_killed=1;
   double timer=1;// actually this timer is relative to sorted times not actual time 
  for(int i=1;i<n;i++){
     double curr_time_to_reach= reach_times[i];
    if((curr_time_to_reach <= (timer) )) return mons_killed;
    mons_killed++;
    timer++;
  }
     
     return mons_killed;

    }
};
// killed  at ith min then can't kill any mons at (i+1)th min but can kil at (i+2 ,, i+3 ,,)
// Game ends if unable to kill any mons if it reach
// sort acc to reach times
// 1 3 4 
// killed={1,3}
// if a monster is 1 min away and weapon is not charged yet
//  monster cannot be killed
92700