codeforces 1066 B heater
菜鸡只配做水题
思路就很简单嘛:肯定扩展的越靠后边越好了
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的更多相关文章
- Codeforces Round #515 (Div. 3) B. Heaters【 贪心 区间合并细节 】
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limi ...
- 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 ...
- Codeforces Round #466 (Div. 2)
所有的题目都可以在CodeForces上查看 中间看起来有很多场比赛我没有写了 其实是因为有题目没改完 因为我不想改,所以就没有写了(大部分题目还是改完了的) 我还是觉得如果是打了的比赛就一场一场写比 ...
- Codeforces Round #466 (Div. 2) Solution
从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Nu ...
- Codeforces Round #515 (Div. 3) 解题报告(A~E)
题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在 ...
- Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...
- 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 ...
- 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. ...
- 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, ...
随机推荐
- 线程和进程PYTHON
基本概念: 计算机一次只能运行一个进程,而一个进程又可以有多个线程,例如百度网盘的上传和下载. 1.线程的创建 .调用threading模块 .创建线程theading.Threads(target ...
- 在进行商业运算时解决BigDecimal的精度丢失问题
System.out.println(0.05+0.01); System.out.println(1.0-0.42); System.out.println(4.015*100); System.o ...
- python note 16 re模块的使用
1.re模块(#regex) # 查找 # findall : 匹配所有 每一项都是列表中的一个元素 import re ret = re.findall('\d+','dawdawd154wadwa ...
- 初始js闭包&事件的冒泡和捕获&EVENT对象
一.初识闭包 function a(){ var n = 0; this.inc = function () { n++; console.log(n); }; } var ...
- docker安装nginx和php
参考文章:https://www.cnblogs.com/boundless-sky/p/7182410.html 1.下载镜像docker pull nginxdocker pull php:7.2 ...
- Chapter_3_JAVA作业
第三章 一 .课前预习 1.1 简述概念,什么是类?什么是对象? 类:在Java中是一种重要的复合数据类型,是组成类的基本要素.(把众多的事物规划,划分成一类是人类在认识个观世界时采用的思维方法). ...
- canvas的使用方法
了解canvas:canvas标签是用作图形绘制,但是通过js脚本来实现的,canvas标签其实只是一个容器 ,最终实现绘制功能肯定是通过js脚本实现. 首先肯定要定义一个canvas标签当做容器 & ...
- python 打包成 windows .EXE
1. 升级pip python -m pip install --upgrade pip 2.安装 pyinstall (打包程序) pip install pyinstaller 3 开始打包(打包 ...
- HTTP之请求消息Request
客户端发送一个HTTP请求到服务器的请求消息包括以下格式: 请求行(request line).请求头部(header).空行和请求数据四个部分组成. 请求行以一个方法符号开头,以空格分开,后面跟着请 ...
- STS中db.properties配置文件
db.name=root db.password=root db.url=jdbc:mysql://localhost:3306/day13?useUnicode=true&character ...