This commit is contained in:
2025-11-03 22:56:42 +08:00
parent b6c8c03411
commit 9de71de750
3 changed files with 81 additions and 0 deletions

33
25/10/3349.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include <vector>
using namespace std;
bool hasIncreasingSubarrays(vector<int>& nums, int k) {
if(k == 1 && nums.size() > 1){
return true;
}
vector<int> s;
int temp = 1;
for(int i = 1;i<nums.size();++i){
if(nums[i] > nums[i-1]){
temp++;
if(temp >= 2 * k){
return true;
}
continue;
}
if(temp >= k){
s.push_back(temp);
if(s.size() > 1){
return true;
}
temp = 1;
continue;
}
while (s.size() > 0)
{
s.pop_back();
}
temp = 1;
}
return false;
}

30
25/11/1578.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include <string>
#include <vector>
#include <iostream>
int minCost(std::string colors, std::vector<int> &neededTime)
{
int n = colors.size();
colors += '#';
int m = 0, count = 0, ans = 0;
for (int i = 0; i < n; ++i)
{
m = std::max(neededTime[i], m);
count += neededTime[i];
if (colors[i] == colors[i + 1])
{
continue;
};
ans += count - m;
m = 0;
count = 0;
}
return ans;
}
int main()
{
std::string c = "abaac";
std::vector<int> need = {1, 2, 3, 4, 5};
std::cout<<minCost(c, need);
}

18
25/11/go/1578.go Normal file
View File

@@ -0,0 +1,18 @@
package A
func minCost(colors string, neededTime []int) int {
count := 0
ans := 0
m := 0
for i := 0; i < len(colors); i++ {
count += neededTime[i]
m = max(m, neededTime[i])
if i != len(colors)-1 && colors[i] == colors[i+1] {
continue
}
ans += count - m
m = 0
count = 0
}
return ans
}