标签:一条直线 时间 log 多少 逻辑 输出 class 一段 space
2017-07-17 11:56:06
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main() { int MIN; int n, length; while(~scanf("%d%d",&n,&length)) { int sum = 0; int * record = new int[n-length+1]; int * num = new int[n]; for(int i= 0 ; i <n ; i ++) { scanf("%d",&num[i]); } for(int i = 0 ; i < length ; i++) sum +=num[i]; MIN = sum; for(int head = 0,tail = length;tail < n; head++,tail++) { sum -= num[head]; sum += num[tail]; if(sum < MIN) MIN = sum; } cout <<MIN <<endl; delete num; delete record; } return 0; }
错误原因:
标签:一条直线 时间 log 多少 逻辑 输出 class 一段 space
原文地址:http://www.cnblogs.com/ilovelianghui/p/7193609.html