codeforces 660C Hard Process
维护一个左右区间指针就可以。
#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的更多相关文章
- Codeforces 660C - Hard Process - [二分+DP]
题目链接:http://codeforces.com/problemset/problem/660/C 题意: 给你一个长度为 $n$ 的 $01$ 串 $a$,记 $f(a)$ 表示其中最长的一段连 ...
- Codeforces 660C Hard Process【二分 Or 尺取】
题目链接: http://codeforces.com/problemset/problem/660/C 题意: 给定0.1组成的数组,可以改变k个0使其为1,问最终可以得到的连续的1的最大长度. 分 ...
- Codeforces 660C Hard Process(尺取法)
题目大概说给一个由01组成的序列,要求最多把k个0改成1使得连续的1的个数最多,输出一种方案. 和CF 676C相似. #include<cstdio> #include<algor ...
- codeforces 660C C. Hard Process(二分)
题目链接: C. Hard Process time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Hard Process(二分)
Hard Process Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submi ...
- codeforces660C
Hard Process CodeForces - 660C You are given an array a with n elements. Each element of a is either ...
- Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...
- Codeforces 660 C. Hard Process (尺取)
题目链接:http://codeforces.com/problemset/problem/660/C 尺取法 #include <bits/stdc++.h> using namespa ...
- Educational Codeforces Round 11 C. Hard Process 前缀和+二分
题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...
随机推荐
- css important
!important是CSS1就定义的语法,作用是提高指定样式规则的应用优先权.语法格式{ cssRule !important },即 写在定义的最后面,例如:box{color:red !impo ...
- Intellij IDEA 14的注册码
IntelliJ IDEA 14 注册码 IntelliJ IDEA 14 下载地址: IntelliJ IDEA 14 下载 分享几个license: (1) key:IDEA value:6115 ...
- makefile的简单写法
makefile 使用方法: vi 一个Makefile文件 CC = g++ // 指的是用什么编译器RM = rm -rf // 定义一个删除的指令(变量)CFLAGS = -c -Wal ...
- ext combobox getValue
使用combobox时,它有一个hiddenName的属性,专门用于提交combobox中value的值. 现假设某combobox的Id为comboId,hiddenName属性的值为hiddenV ...
- yum和rpm命令详解
rpm,全称RPM Package Manager,是RedHat发布的,针对特定硬件,已经编译好的软件包.安装之后就可以使用,不需要自行编译,以及之前对软件和硬件的检测,目录的配置等动作. yum, ...
- bzoj 2555: SubString 后缀自动机+LCT
2555: SubString Time Limit: 30 Sec Memory Limit: 512 MBSubmit: 688 Solved: 235[Submit][Status][Dis ...
- A Full Hardware Guide to Deep Learning
A Full Hardware Guide to Deep Learning Deep Learning is very computationally intensive, so you will ...
- MongoDB实战指南(五):MongoDB中的聚集分析
聚集操作是对数据进行分析的有效手段.MongoDB主要提供了三种对数据进行分析计算的方式:管道模式聚集分析,MapReduce聚集分析,简单函数和命令的聚集分析. 1. 管道模式进行聚集 这里所说的管 ...
- 详解浏览器缓存机制与Apache设置缓存
一.详解浏览器缓存机制 对于,如何说明缓存机制,在网络上找到了两张图,个人认为思路是比较清晰的.总结时,上图. 这里需要注意的有两点: 1.Last-Modified.Etag是响应头里的数据 2.I ...
- 8. Unity异常警告错误处理方法
一. The AnimationClip 'cube1_anim' used by the Animation component 'Cube1' must be marked as Legacy. ...