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, ...
随机推荐
- [Solution] 969. Pancake Sorting
Difficulty: Medium Problem Given an array A, we can perform a pancake flip: We choose some positive ...
- java Graphics2D drawString()内容换行问题
//字符串总宽度 private int getStringLength(Graphics g,String str) { char[] strcha=str.toCharArray(); int s ...
- 解决cpplint在Python 3下没有任何输出的问题
修改cpplint.py:1. main()中注释掉 # sys.stderr = codecs.StreamReaderWriter(sys.stderr, # codecs.getreader ...
- PRD是什么
产品需求文档(Product Requirement Document,PRD)的英文简称.是将商业需求文档(BRD)和市场需求文档(MRD)用更加专业的语言进行描述
- java中比较特殊的三个浮点数Infinity、-Infinity、NaN
学过javaScript的应该都知道,在js中的数值型number类型中有几个特殊的数,一个正无穷大.一个负无穷大.一个不是一个数NaN. 后来无意中发现java中也有这三个数,不过这三个数是浮点数, ...
- http/2.0与http/1.1的区别
http/2是http协议自1999年http1.1发布后的首个更新 主要基于SPDY协议 2.0 采用二进制 而不是文本格式 完全多路复用 而不是有序并阻塞的 只需要一个连接即可实现并行 使 ...
- SPA
为什么用SPA 1. 减少服务器压力 如果不用spa 那么每次切换页面的时候,就会向服务器发送一个请求 服务器返回一个html文件 如果使用了SPA 在切换时,不需要请求服务器,只要通过本地 ...
- python读取数据库出txt报表
python出报表使用到了数据库访问,文件读写,字符串切片处理.还可以扩展到电子邮件的发送,异常处理以及定时批任务. 总之在学习中发现还是有蛮多乐趣在其中. #coding=utf-8 ' impor ...
- ABP框架记录
1.先在Core项目中建立模型Models>Model.cs/ModelManager.cs 2.在Application中建立接口和具体类:IModelAppService.csModelAp ...
- AD16 PCB重新定义板型时没有Redefine Board Shape
1.高版本的AD都没有“Redefine Board Shape” 2.在Keep-Out-Layer层,做好了板子的外形,把外形都选中后,然后快捷键D-S-D即可.