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. SPOJ 0962 Intergalactic Map

    题目大意:在一个无向图中,一个人要从A点赶往B点,之后再赶往C点,且要求中途不能多次经过同一个点.问是否存在这样的路线.(3 <= N <= 30011, 1 <= M <= ...

  2. HDOJ 1339 A Simple Task(简单数学题,暴力)

    Problem Description Given a positive integer n and the odd integer o and the nonnegative integer p s ...

  3. 重温Java的类加载机制

    原文地址:http://blog.csdn.net/hitxueliang/article/details/19992851 首先简要的说一下类加载器   我们知道,虚拟机的指令存储在以.class为 ...

  4. New Year Permutation(Floyd+并查集)

    Description User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to mak ...

  5. A - Network of Schools - poj 1236(求连通分量)

    题意:学校有一些单向网络,现在需要传一些文件,1,求最少需要向几个学校分发文件才能让每个学校都收到,2,需要添加几条网络才能在任意一个学校分发都可以传遍所有学校. 分析:首先应该求出来连通分量,进行缩 ...

  6. hibernate 一对多双向关联 详解

    一.解析: 1.  一对多双向关联也就是说,在加载班级时,能够知道这个班级所有的学生. 同时,在加载学生时,也能够知道这个学生所在的班级. 2.我们知道,一对多关联映射和多对一关联映射是一样的,都是在 ...

  7. [React] React Router: Route Parameters

    A router library is no good if we have to hardcode every single route in our application. In this le ...

  8. jdk\willy\集群安装

    一.telnet用户验证端口: yum install telnet #也可以使用 yum install telnet-ssl 安装支持SSL的telnet方式,这样安全一些,不建议使用标准的tel ...

  9. 用Ant实现Java项目的自动构建和部署(转)

    Ant是一个Apache基金会下的跨平台的构件工具,它可以实现项目的自动构建和部署等功能.在本文中,主要让读者熟悉怎样将Ant应用到Java项目中,让它简化构建和部署操作. 一.            ...

  10. Jquery手机发送短信之后,进入倒计时状态

    在做手机网站开发的时候,难免发生意外.这时候,就是你展示人格魅力的时候啦! 下面是自己写的一个发送验证码给手机之后,进入的一个倒计时的效果 js代码,我可是连<script type=" ...