D - Single-use Stones
Title: Frogs cross the river, it's a bit violent, Gou.
Solution: It's actually very simple. Let's think about it this way. The distance the frog moves is , then every time the frog moves we can see it as Such a segment is moving (jump out We don't care about him outside), what really affects whether we can get to the other side of the river is this Whether there are enough footholds, we find The least foothold in the .
#include<cstdio>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<limits.h>
#include<string.h>
#include<map>
#include<list>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf int(0x3f3f3f3f)
#define mod int(1e9+9)
#define eps double(1e-6)
#define pi acos(-1.0)
#define lson root << 1
#define rson root << 1 | 1
ll n,l;
ll a[100005];
ll sum[100005];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(sum,0,sizeof(sum));
ll ans=LONG_MAX;
cin>>n>>l;
for(int i=1;i<n;i++)
{
cin>>a[i];
sum[i]=sum[i-1]+a[i];
}
for(int i=l;i<n;i++)
ans=min(ans,sum[i]-sum[i-l]);
cout<<ans<<endl;
}