This commit is contained in:
2025-12-24 13:00:39 +08:00
parent f14466081c
commit 2a498251b6

20
25/12/3074.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include <algorithm>
#include <numeric>
#include <vector>
class Solution {
public:
int minimumBoxes(std::vector<int>& apple, std::vector<int>& capacity) {
int sum = std::accumulate(apple.begin(),apple.end(),0);
std::sort(capacity.begin(),capacity.end(),[](int a,int b){return a>b;});
int ans = 0;
for(auto c : capacity){
sum -= c;
ans++;
if (sum <= 0) {
break;
}
}
return ans;;
}
};