菜鸡只配做水题

思路就很简单嘛:肯定扩展的越靠后边越好了

0 0 1 0 1 1 0 0

假设范围是3 ,第一个1一定要选上,第2、3个肯定选3啦,越靠后边就一定能节省更多的点,没看出来和子问题有什么联系,基本上就是贪心

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define x first
#define y second
using namespace std;
const int maxn = ;
int a[maxn];
vector<int> q;
int main()
{
//freopen("in.txt","r",stdin);
int n,k;
scanf("%d %d",&n,&k);
int cnt = ;
q.push_back();
for(int i = ; i <= n; ++i)
{
scanf("%d",a+i);
if(a[i] == ){
q.push_back(i);
cnt ++;
}
}
int cn = ;
int pos = ;
int ans = ;
while(cn < n)
{
int i;
for(i = pos + ; i < q.size(); ++i)
{
if(cn < q[i]-(k-)-)
break;
}
if(i == pos + )
{
cout << - << endl;
return ;
} pos = i-;
cn = q[pos]+(k-);
ans ++;
}
cout << ans << endl;
}

codeforces 1066 B heater的更多相关文章

  1. Codeforces Round #515 (Div. 3) B. Heaters【 贪心 区间合并细节 】

    任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limi ...

  2. CodeForces Round #515 Div.3 B. Heaters

    http://codeforces.com/contest/1066/problem/B Vova's house is an array consisting of nn elements (yea ...

  3. Codeforces Round #466 (Div. 2)

    所有的题目都可以在CodeForces上查看 中间看起来有很多场比赛我没有写了 其实是因为有题目没改完 因为我不想改,所以就没有写了(大部分题目还是改完了的) 我还是觉得如果是打了的比赛就一场一场写比 ...

  4. Codeforces Round #466 (Div. 2) Solution

    从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Nu ...

  5. Codeforces Round #515 (Div. 3) 解题报告(A~E)

    题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在 ...

  6. Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum

    E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...

  7. CodeForces Round #515 Div.3 D. Boxes Packing

    http://codeforces.com/contest/1066/problem/D Maksim has nn objects and mm boxes, each box has size e ...

  8. CodeForces Round #515 Div.3 C. Books Queries

    http://codeforces.com/contest/1066/problem/C You have got a shelf and want to put some books on it. ...

  9. CodeForces Round #515 Div.3 A. Vova and Train

    http://codeforces.com/contest/1066/problem/A Vova plans to go to the conference by train. Initially, ...

随机推荐

  1. webpack优化以及node版本

    最近做的这个项目webpack用的是1.X的版本,真的非常多的坑,然后最近在疯狂的做优化: 事情的起因是每次我npm run dev的时侯都需要5分钟+,这个速度真的是难以忍受,然后就尝试去做项目的优 ...

  2. ./configure -build,-host,-target设置

    build:执行代码编译的主机,正常的话就是你的主机系统.这个参数一般由config.guess来猜就可以.当然自己指定也可以.host:编译出来的二进制程序所执行的主机,因为绝大多数是如果本机编译, ...

  3. python读取数据库出txt报表

    python出报表使用到了数据库访问,文件读写,字符串切片处理.还可以扩展到电子邮件的发送,异常处理以及定时批任务. 总之在学习中发现还是有蛮多乐趣在其中. #coding=utf-8 ' impor ...

  4. Centos7 出现Welcome to emergency mode!

    做mount挂载时,修改了  /etc/fstab 文件,导致Centos7重启时出现如下图所示错误: Welcome to emergency mode! After logging in, typ ...

  5. angular使用Md5加密

    一.现象 用户登录时需要记住密码的功能,在前端需要对密码进行加密处理,增加安全性 二解决 1.利用npm(如果没有,先自行安装npm)安装ts-md5 npm install ts-md5 --sav ...

  6. dskinlite(uieasy mfc界面库)使用记录1: schema验证xml

    市场上的MFC第三方库很多,最终选定dskinlite企业版,成熟度比较高,当然价格也略贵. 在2017年仍然使用MFC是有些另类,但特定场景很适用,也适合不愿转型的老程序员. 目前处于学习阶段,欢迎 ...

  7. vim 中文乱码怎么解决

    一般来说只需要正确设置vim的编码识别序列就很少会遇到乱码问题: set fileencodings=ucs-bom,utf-8,utf-16,gbk,big5,gb18030,latin1 这个设置 ...

  8. docker构建镜像

    Docker 提供了两种构建镜像的方法: docker commit 命令Dockerfile 构建文件 示例: Dockerfile FROM golang:1.7.5 #基础镜像 RUN apt- ...

  9. python中打印一个字符串中有多少个单词

    1.for实现: str1 = str.strip(input("please input a str:"))n = 1i = 0for i in range(len(str1)- ...

  10. .NET framework访问Oracle的几种方法

    首先介绍下开发环境:WIn10 64bit+Visual Studio 2015+Oracle10ClientWin32(只是客户端,如果安装整个数据库也是可以的) 目前了解C#中连接Oracle数据 ...