diff --git a/25/12/1351.cpp b/25/12/1351.cpp new file mode 100644 index 0000000..a9d6dfb --- /dev/null +++ b/25/12/1351.cpp @@ -0,0 +1,8 @@ +#include + +class Solution { +public: + int countNegatives(std::vector>& grid) { + + } +}; \ No newline at end of file diff --git a/25/12/comp/28q1.cpp b/25/12/comp/28q1.cpp new file mode 100644 index 0000000..9398eab --- /dev/null +++ b/25/12/comp/28q1.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +class Solution { +public: + long long maximumScore(std::vector& nums) { + std::vector pre; + int n = nums.size(); + long long sum = 0; + for (int i = 0; i < n; i++) { + sum += nums[i]; + pre.push_back(sum); + } + int mins = nums[n - 1]; + long long ans = pre[n-2] - mins; + for (int i = n - 3; i >= 0; i--) { + mins = std::min(mins,nums[i+1]); + ans = std::max(ans,pre[i] - mins); + } + return ans; + } +}; \ No newline at end of file diff --git a/25/12/comp/28q2.cpp b/25/12/comp/28q2.cpp new file mode 100644 index 0000000..37ba6da --- /dev/null +++ b/25/12/comp/28q2.cpp @@ -0,0 +1,15 @@ +#include +class Solution { +public: + long long minimumCost(int cost1, int cost2, int costBoth, int need1, int need2) { + if (costBoth >= cost1 + cost2) { + return (long long)cost1 * need1 + (long long)cost2 * need2; + } + int m1 = std::min(need1,need2); + long long a2 = (long long)std::max(need1,need2) * costBoth; + long long ans = (long long)m1 * costBoth; + ans += (long long)(need1 - m1) * cost1; + ans += (long long)(need2 - m1) * cost2; + return std::min(ans,a2); + } +}; \ No newline at end of file diff --git a/25/12/comp/28q3.cpp b/25/12/comp/28q3.cpp new file mode 100644 index 0000000..ef335e9 --- /dev/null +++ b/25/12/comp/28q3.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + int minAllOneMultiple(int k) { + if (k%2==0 || k%5==0) { + return -1; + } + int remainder = 1; + for (int i = 1 ;i<=k;i++) { + if (remainder % k == 0) { + return i; + } + // (a * 10 + 1) % k = ((a % k) * 10 + 1) % k + remainder = (remainder * 10 + 1) % k; + } + return -1; + } +}; \ No newline at end of file