题解 | 01序列

01序列

https://www.nowcoder.com/practice/b0c948dbe577485598b982a430d65c39

#include <iostream>
using namespace std;
const int N = 1e5+10;

int main() {
    int m,n;cin>>m;
    bool b[N]={0};
    int replace=0;
    for(int i=1;i<=m;i++)
        cin>>b[i];
    cin>>n;
    for(int i=1;i<=m;i++)
        if(!b[i]&&!b[i-1]&&!b[i+1])
        {
            replace++;
            b[i] = 1; 
        }
    if(replace>=n) cout<<"true";
    else cout<<"false";
    return 0;
}

全部评论
天才啊
点赞 回复 分享
发布于 2025-10-25 09:14 浙江

相关推荐

04-15 13:42
四川大学 Java
蹲蹲offerrr:快投吧,有点晚现在
点赞 评论 收藏
分享
评论
6
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务