题目:
代码(首刷看解析):
class Solution {
public:
vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {
vector<int> pairs;
sort(potions.begin(),potions.end());
for(auto& i:spells){
long long target = (success+i-1)/i - 1;
pairs.push_back(potions.size()-(upper_bound(potions.begin(),potions.end(),target)-potions.begin()));
}
return pairs;
}
};