http://codeforces.com/contest/363/problem/B

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 500001
using namespace std;
const int inf=<<; int n,k;
int a[maxn];
int min1;
int sum[maxn]; int main()
{
while(scanf("%d%d",&n,&k)!=EOF)
{
min1=inf;
sum[]=;
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
sum[i]=sum[i-]+a[i];
}
int c=;
for(int i=; i<=n; i++)
{
if(sum[i+k-]-sum[i-]<min1&&i+k-<=n)
{
c=i;
min1=sum[i+k-]-sum[i-];
}
}
printf("%d\n",c);
}
return ;
}

cf B. Fence的更多相关文章

  1. CF 484E - Sign on Fence

    E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...

  2. (困难) CF 484E Sign on Fence,整体二分+线段树

    Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence o ...

  3. CF&&CC百套计划4 Codeforces Round #276 (Div. 1) E. Sign on Fence

    http://codeforces.com/contest/484/problem/E 题意: 给出n个数,查询最大的在区间[l,r]内,长为w的子区间的最小值 第i棵线段树表示>=i的数 维护 ...

  4. cf B. Color the Fence

    http://codeforces.com/contest/349/problem/B 贪心 #include <cstdio> #include <cstring> #inc ...

  5. cf 448c Painting Fence

    http://codeforces.com/problemset/problem/448/C 题目大意:给你一个栅栏,每次选一横排或竖排染色,求把全部染色的最少次数,一个点不能重复染色. 和这道题有点 ...

  6. CF集萃1

    因为cf上一堆水题,每个单独开一篇博客感觉不太好,就直接放一起好了. CF1096D Easy Problem 给定字符串,每个位置删除要代价.求最小代价使之不含子序列"hard" ...

  7. CF数据结构练习

    1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...

  8. 【CF484E】Sign on Fence(主席树)

    [CF484E]Sign on Fence(主席树) 题面 懒得贴CF了,你们自己都找得到 洛谷 题解 这不就是[TJOI&HEOI 排序]那题的套路吗... 二分一个答案,把大于答案的都变成 ...

  9. OpenJ_Bailian - 1037 A decorative fence

    Discription Richard just finished building his new house. Now the only thing the house misses is a c ...

随机推荐

  1. oschina企业应用

    企业应用 6企业搜索引擎 20ESB企业服务总线 34LaTeX排版系统 32软电话交换机/VOIP/PBX 9邮件列表管理 42大数据 21开源医疗项目 12人力资源管理 15家庭自动化系统 16E ...

  2. python通过代理刷网页点击量

    python通过代理刷网页点击量 更新异常处理情况 @time 2013-0803 更新循环里计数问题和随机等待时间问题 #!/usr/bin/python #-*- coding:utf-8 -*- ...

  3. Response.Expires 属性 (转载于疯狂客的BLOG)

    Expires 属性 Expires 属性指定了在浏览器上缓冲存储的页距过期还有多少时间.如果用户在某个页过期之前又回到此页,就会显示缓冲区中的版本 语法 Response.Expires [= nu ...

  4. Android AlertDialog全屏显示去除白色边框

    使用styles.xml风格: Style.xml代码 <style name="FullScreenDialog" parent="android:style/T ...

  5. [转]The culture name list in C#

    Culture Names [C#] This example shows how to get all culture names in the .NET Framework. Use static ...

  6. iOS-网络编程(二)文件上传和断点离线下载

    一. iOS中发送HTTP请求的方案 在iOS中,我们常用发送HTTP请求的方案有苹果原生(自带)NSURLConnection:用法简单,最古老最经典最直接的一种方案 (iOS 9.0弃用)NSUR ...

  7. 【调试技巧】FireFox作为移动端的设置

    1.在地址栏输入“about:config”,按下回车进入设置菜单. 2.找到“general.useragent.override”,如果没有这一项,则点右键“新建”->“字符串”,输入这个字 ...

  8. Android学习路线(二十七)键值对(SharedPreferences)存储

    假设你又一个相对较小的键值对数据想要保存,你应该使用SharedPreferences APIs.一个SharedPreferences 对象指向一个包括键值对的文件,它提供简单的方法来读写他们.每一 ...

  9. [ES6] Export class and variable

    Export variable: export const MAX_USERS = 3; export const MAX_REPLIES = 3; Export default class: exp ...

  10. Android Fragment详解(二):Fragment创建及其生命周期

    Fragments的生命周期 每一个fragments 都有自己的一套生命周期回调方法和处理自己的用户输入事件. 对应生命周期可参考下图: 创建片元(Creating a Fragment) To c ...