From 2a498251b67907a1aea84166aaacbbfc0293887f Mon Sep 17 00:00:00 2001 From: wolves Date: Wed, 24 Dec 2025 13:00:39 +0800 Subject: [PATCH] routine --- 25/12/3074.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 25/12/3074.cpp diff --git a/25/12/3074.cpp b/25/12/3074.cpp new file mode 100644 index 0000000..5ecde1d --- /dev/null +++ b/25/12/3074.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +class Solution { +public: + int minimumBoxes(std::vector& apple, std::vector& 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;; + } +}; \ No newline at end of file