3207. Maximum Points After Enemy Battles
#define ll long long
class Solution {
public:
long long maximumPoints(vector<int>& enemyEnergies, int currentEnergy)
{
sort(enemyEnergies.begin(), enemyEnergies.end());
int n = enemyEnergies.size();
if (currentEnergy < enemyEnergies[0]) return 0;
ll availableEngergy = currentEnergy;
for (int j = n - 1; j > 0; --j)
{
availableEngergy += enemyEnergies[j];
}
return availableEngergy / enemyEnergies[0];
}
};
- T:
- S: