@[SixSeven](/user/1286053)
思路: 1.枚举天数。 2.每次清洗时统计所需t型衣服的最大值。 3.再结尾处再判断一次即可。
```
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
string s;
cin>>n>>m;
cin>>s;
int x=0,y=0,ans=0;
for (int i=0;i<(int)s.size();i++){
if(s[i]=='0') {
if(x>m){
y+=x-m;
}
ans=max(ans,y);
x=0,y=0;
}
else if (s[i]=='1') {
x++;
}
else {
y++;
}
}
if(x>m){
y+=x-m;
}
ans=max(ans,y);
x=0,y=0;
cout<<ans<<endl;
}
```
网上粘的
by zxjn @ 2024-04-13 20:47:19
@[zxjn](/user/891168) 谢谢
by SixSeven @ 2024-04-13 20:47:42
@[SixSeven](/user/1286053) https://www.luogu.com.cn/problem/AT_abc332_c
by _s_z_y_ @ 2024-04-13 21:05:14
@ _s_z_y_ 谢谢
by SixSeven @ 2024-04-13 21:06:06