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, ...
随机推荐
- pandas 中有关isin()函数的介绍,python中del解释
- Codeforces Round #491 (Div. 2)
Codeforces Round #491 (Div. 2) https://codeforces.com/contest/991 A #include<bits/stdc++.h> us ...
- A Boring Problem UVALive - 7676
16年北京现场赛的题,全场过的队30+. 初看只知道 O(N^2logK)的暴力,以为是什么变换. 仔细发现活用 二项式定理 就行. #include <bits/stdc++.h> us ...
- vue使用qrcode插件生成二维码
参考:https://www.jianshu.com/p/d3883e020d99 步骤: 第一步:vue-cli下载插件 cnpm install --save qrcodejs2 第二步:组件中引 ...
- XML字符串转为Map
import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException;import java.util.Ha ...
- vue iview render里面写时间截取
render: (h, params) => {params.row.execDate = (params.row.execDate ? params.row.execDate.substr(0 ...
- gem 安装问题
错误提示: ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) SSL_connect returned=1 errno=0 ...
- Intellij Idea15 快捷键设置大全
一:菜单快捷键 快捷键 设置Bar快捷键,参考文章 进入(Enter Full Screen) Alt+S /(Status Bar) Alt+T /(Toolbar) Alt+B ...
- css三列布局之双飞翼pk圣杯
三列布局:两边定宽,中间自适应! 看到这个问题,我第一眼想的就是两边定宽float左右,中间加一个margin宽度自适应或者直接设一个overflow:hidden触发bfc机制,这样也可以,看上去也 ...
- php的运行原理、cgi对比fastcgi以及php-cgi和php-fpm之间的联系区别
最近项目中本地测试环境遇到了windows环境下的nginx使用file_get_contents/curl访问php文件导致的阻塞问题,一直在找解决的方案,这个问题研究了三天终于找到了解决方案,特别 ...