cf B. Fence
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的更多相关文章
- CF 484E - Sign on Fence
E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...
- (困难) CF 484E Sign on Fence,整体二分+线段树
Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence o ...
- 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的数 维护 ...
- cf B. Color the Fence
http://codeforces.com/contest/349/problem/B 贪心 #include <cstdio> #include <cstring> #inc ...
- cf 448c Painting Fence
http://codeforces.com/problemset/problem/448/C 题目大意:给你一个栅栏,每次选一横排或竖排染色,求把全部染色的最少次数,一个点不能重复染色. 和这道题有点 ...
- CF集萃1
因为cf上一堆水题,每个单独开一篇博客感觉不太好,就直接放一起好了. CF1096D Easy Problem 给定字符串,每个位置删除要代价.求最小代价使之不含子序列"hard" ...
- CF数据结构练习
1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...
- 【CF484E】Sign on Fence(主席树)
[CF484E]Sign on Fence(主席树) 题面 懒得贴CF了,你们自己都找得到 洛谷 题解 这不就是[TJOI&HEOI 排序]那题的套路吗... 二分一个答案,把大于答案的都变成 ...
- OpenJ_Bailian - 1037 A decorative fence
Discription Richard just finished building his new house. Now the only thing the house misses is a c ...
随机推荐
- Windows服务器Pyton辅助运维--03.安装Visual Studio 的 Python 开发插件 PTVS
PTVS (Python Tools for Visual Studio) http://pytools.codeplex.com/ 当前版本:2.1 RC PTVS (Python Tools fo ...
- POJ-2386(深广搜基础)
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 25322 Accepted: 12759 D ...
- 设计模式16---设计模式之组合模式(Composite)(行为型)
1.场景模拟 使用软件模拟大树的根节点和树枝节点和叶子节点 抽象为两类,容器节点和叶子节点 2.不用模式的解决方案 package demo14.composite.example1; import ...
- CSU1659: Graph Center(最短路)
Description The center of a graph is the set of all vertices of minimum eccentricity, that is, the s ...
- Redis Install
Redis 是一个高性能的key-value数据库. redis的出现,很大程度补偿了memcached这类keyvalue存储的不足,在部分场合可以对关系数据库起到很好的补充作用.它提供了Pytho ...
- Codeforces 220B - Little Elephant and Array 离线树状数组
This problem can be solve in simpler O(NsqrtN) solution, but I will describe O(NlogN) one. We will s ...
- static——第一次执行与它以后执行时结果不一样
void generate_initializer(char* string); int _tmain(int argc, _TCHAR* argv[]) { "}; ; i < ; ...
- Android 属性动画(二)
当然了属性动画还有一部分的知识点,也能做出很不错的效果,将在本篇博客为您展示~ 1.如何使用xml文件来创建属性动画 大家肯定都清楚,View Animator .Drawable Animator都 ...
- zabbix监控应用连接数
zabbix使用用户自定义键值来监控应用系统连接数: 1.修改配置文件zabbix_agentd.conf 格式: UserParameter=<key>,<shell comman ...
- RedHat下GCC及G++的安装
GCC的安装: 切换到安装光盘目录下: #mount /dev/cdrom /mnt/cdrom #cd /mnt/cdrom 安装GCC依赖的*rpm程序,必须按照顺序依次执行: #rpm - ...