From ba370e1cc846065a5ed535e93f2d00b3d5ec2cf5 Mon Sep 17 00:00:00 2001 From: wolves Date: Thu, 25 Dec 2025 20:40:25 +0800 Subject: [PATCH] routine --- 25/12/3075.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 25/12/3075.cpp diff --git a/25/12/3075.cpp b/25/12/3075.cpp new file mode 100644 index 0000000..485ba65 --- /dev/null +++ b/25/12/3075.cpp @@ -0,0 +1,18 @@ +#include +#include + +class Solution { +public: + long long maximumHappinessSum(std::vector &happiness, int k) { + long long ans = 0; + std::sort(happiness.begin(), happiness.end(), + [](int a, int b) { return a > b; }); + for (int i = 0; i < k && i < happiness.size(); i++) { + if (happiness[i] < i) { + break; + } + ans += happiness[i] - i; + } + return ans; + } +}; \ No newline at end of file