Codeforces Round #476 (Div. 2) [Thanks, ********!] D - Single-use Stones(思维)
程序员文章站
2022-06-03 14:39:02
...
D - Single-use Stones
题意:青蛙过河,有点暴力啊,苟.
解:其实很简单,我们这样想,青蛙的移动距离是,那么每次青蛙移动我们都可以看作是这么一段在移动(跳出外面的我们已经不用管他了),真正影响是否能到河对面的是这里是否有足够的落脚点,我们找到里最少的落脚点即是.
#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;
}
上一篇: Docker多端口映射和镜像迁移多份部署
下一篇: windows 2003下配置php环境
推荐阅读
-
构造思维+树形结构 Codeforces Round #612 (Div. 2) D题 Numbers on Tree
-
Codeforces Round #583 (Div. 1 + Div. 2,) D. Treasure Island(dfs+思维)
-
D. Rarity and New Dress(思维+动态规划)Codeforces Round #662 (Div. 2)
-
Codeforces Raif Round 1 (Div. 1 + Div. 2) D. Bouncing Boomerangs(思维+构造)
-
Codeforces Round #476 (Div. 2) [Thanks, ********!] D - Single-use Stones(思维)
-
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2):D. Minimum path(思维)
-
Educational Codeforces Round 50 (Rated for Div. 2) D. Vasya and Arrays(前缀和,思维)
-
Codeforces Round #630 (Div. 2) D. Walk on Matrix(思维+构造)
-
Educational Codeforces Round 48 (Rated for Div. 2) D. Vasya And The Matrix(思维/构造)
-
D. Rarity and New Dress(思维+动态规划)Codeforces Round #662 (Div. 2)