Editorial for Champion Contest
                Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
                Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
There are several ways to approach this problem. I will be explaining one of them.
Since  is quite big, we cannot do a simple brute-force 
 solution.
The solution is to sort the array, and binary search for the farthest indexed champion which the current champion can defeat. This is an  solution.
We can precompute an array of , where the 
 index of the 
 array will keep the number of champions that has a lower strength value than the 
 champion. This way, when calculating the number of champions the current champion can defeat, all we need to do is binary search, then subtract 
, where 
 is the current champion.
Time Complexity: 
Comments