CodeForces 363B Fence
2015-07-03 20:39
351 查看
Fence
Time Limit: 1000msMemory Limit: 262144KB
This problem will be judged on CodeForces. Original ID: 363B
64-bit integer IO format: %I64d Java class name: (Any)
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights.
#include <bits/stdc++.h> using namespace std; const int maxn = 200010; int n,k,sum[maxn]; int main(){ while(~scanf("%d %d",&n,&k)){ int theMin = INT_MAX,idx = -1; for(int i = 1; i <= n; ++i){ scanf("%d",sum+i); sum[i] += sum[i-1]; if(i >= k && sum[i] - sum[i-k] < theMin){ theMin = sum[i] - sum[i-k]; idx = i - k + 1; } } printf("%d\n",idx); } return 0; }
View Code
相关文章推荐
- fedora22上terminal如何变成彩色?
- js中会用到的键盘码
- Javascript之对象的继承
- HTML5 新增绘图功能
- javascript的解析顺序和变量作用域
- javascript函数详解
- javascript流程控制
- JS代码验证用户身份证
- JSP调用DLL文件的公用方法
- jquery根据name取值
- jquery 回车事件
- 跨终端实践-天猫试戴的解决方案
- 天猫Web架构/Pad客户端负责人:如何评价 React Native?
- JavaScript学习第一课
- jsp语法
- js控制不同的时间段显示不同的css样式的实例代码
- CSS透明属性详解代码
- JSP,EL,JSTL快速入门
- CSS透明属性详解代码
- 利用CSS3实现气泡效果的教程