菜鸡只配做水题

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

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. 前端生成pdf

    https://stackoverflow.com/questions/31610129/pdfmake-html-table-to-pdfmake-table https://www.jianshu ...

  2. linux学习笔记:关于环境变量

    (摘自https://blog.csdn.net/llzk_/article/details/53813266之后整合) 1.linux系统的条件 Linux是一个多用户的操作系统,每个用户登录系统时 ...

  3. java中null是什么,以及使用中要注意的事项

    1.null既不是对象也不是一种类型,它仅是一种特殊的值,你可以将其赋予任何引用类型,你也可以将null转化成任何类型,例如: Integer i=null; Float f=null; String ...

  4. Laravel 学习笔记

    1. 简介 2. 运行环境要求 2.1 PHP版本 >= 5.5.9 2.2 Mcrypt PHP 扩展 --------------------------php的加密扩展,提供多种加密算法 ...

  5. IDEA中添加javap反编译

  6. css文本垂直居中的实现

    本案例已经有新的比较简便的解决方案,可以直接采用 vertical-align:middle 样式对行内元素进行垂直居中布局,详见: 微信小程序开发——如何让商品标题类文本根据内容长度垂直居中. 以下 ...

  7. Cisco交换机设置备份

    conf tusername xa privilege 3 secret xxx aaa new-modelaaa authentication login default local enablea ...

  8. PCIe link up bug 分析

    Xilinx两块开发版PCIe link up时间相差很大,Virtex-6开发版PCIe link up时间超过60ms,而Virtex-7 PCIe link up时间只有~25ms.   分析过 ...

  9. tiny4412 --Uboot移植(6) SD卡驱动,启动内核

    开发环境:win10 64位 + VMware12 + Ubuntu14.04 32位 工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-g ...

  10. [转] spring framework体系结构及内部各模块jar之间的maven依赖关系

    很多人都在用spring开发java项目,但是配置maven依赖的时候并不能明确要配置哪些spring的jar,经常是胡乱添加一堆,编译或运行报错就继续配置jar依赖,导致spring依赖混乱,甚至下 ...