维护一个左右区间指针就可以。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
using namespace std;
int main(){
int n,m;
int a[];
while(~scanf("%d%d",&n,&m)){
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
int l,r,k,rr,ll;
l=,r=,rr=-,ll=,k=;
while(r<=n){
if(rr-ll<r-l){
rr=r;
ll=l;
}
if(a[++r]==){
k++;
}
while(k>m){
if(a[l++]==){
k--;
}
}
}
printf("%d\n",rr-ll+);
for (int i = ll; i <= rr ; ++i)
{
/* code */
a[i]=;
}
for(int i=;i<=n;i++){
printf("%d ",a[i]);
}
}
return ;
}

codeforces 660C Hard Process的更多相关文章

  1. Codeforces 660C - Hard Process - [二分+DP]

    题目链接:http://codeforces.com/problemset/problem/660/C 题意: 给你一个长度为 $n$ 的 $01$ 串 $a$,记 $f(a)$ 表示其中最长的一段连 ...

  2. Codeforces 660C Hard Process【二分 Or 尺取】

    题目链接: http://codeforces.com/problemset/problem/660/C 题意: 给定0.1组成的数组,可以改变k个0使其为1,问最终可以得到的连续的1的最大长度. 分 ...

  3. Codeforces 660C Hard Process(尺取法)

    题目大概说给一个由01组成的序列,要求最多把k个0改成1使得连续的1的个数最多,输出一种方案. 和CF 676C相似. #include<cstdio> #include<algor ...

  4. codeforces 660C C. Hard Process(二分)

    题目链接: C. Hard Process time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. Hard Process(二分)

    Hard Process Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submi ...

  6. codeforces660C

    Hard Process CodeForces - 660C You are given an array a with n elements. Each element of a is either ...

  7. Educational Codeforces Round 11 C. Hard Process 二分

    C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...

  8. Codeforces 660 C. Hard Process (尺取)

    题目链接:http://codeforces.com/problemset/problem/660/C 尺取法 #include <bits/stdc++.h> using namespa ...

  9. Educational Codeforces Round 11 C. Hard Process 前缀和+二分

    题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...

随机推荐

  1. Python 基础篇:字符串、列表操作

    字符串操作 判断是否为数字 string = "200" string.isdigit() >>false 待完善.. 列表操作 列表是我们最以后最常用的数据类型之一, ...

  2. osg 基本几何图元

    转自:osg 基本几何图元 //osg 基本几何图元 // ogs中所有加入场景中的数据都会加入到一个Group类对象中,几何图元作为一个对象由osg::Geode类来组织管理. // 绘制几何图元对 ...

  3. Python中map,filter,reduce,zip的应用

    事例1: l=[('main', 'router_115.236.xx.xx', [{'abc': 1}, {'dfg': 1}]), ('main', 'router_183.61.xx.xx', ...

  4. 【BZOJ】1070: [SCOI2007]修车

    1070: [SCOI2007]修车 Description 同 一时刻有N位车主带着他们的爱车来到了汽车维修中心.维修中心共有M位技术人员,不同的技术人员对不同的车进行维修所用的时间是不同的.现在需 ...

  5. HDU 3749 Financial Crisis

    Financial Crisis 题意:给一个图,包含N ( 3 <= N <= 5000 )个点, M ( 0 <= M <= 10000 )条边 and Q ( 1 < ...

  6. Python标准库与第三方库详解(转载)

    转载地址: http://www.codeweblog.com/python%e6%a0%87%e5%87%86%e5%ba%93%e4%b8%8e%e7%ac%ac%e4%b8%89%e6%96%b ...

  7. C# const和statci readonly区别

    1.const 是属于编译时的变量,它定义的常量是在对象初始化时赋值,以后不能改变他的值. 它适用于两种场景:1.取值永久不变(比如圆周率.一天包含的小时数.地球的半径等)  2.对程序性能要求非常苛 ...

  8. NUTCH Exception in thread "Thread-12751" java.lang.OutOfMemoryError: PermGen space

    转载自 :http://greemranqq.iteye.com/blog/1705867转载自:http://www.cnblogs.com/xwdreamer/archive/2011/11/21 ...

  9. nutch 采集到的数据与实际不符

    现象,这个网站我总计能抽取将近500个URL,但实际只抽取了100条 解析:nutch默认从一个页面解析出的链接,只取前 100 个. <property> <name>db. ...

  10. jquery怎么实现左右滑动的问题

    var len = $("#b span").length, curindex = 0; $("#leftRun").click(function(){ if( ...