90pts

P2627 [USACO11OPEN] Mowing the Lawn G

_Lightning_ @ 2024-04-04 20:54:30

```cpp #include<bits/stdc++.h> #define int long long using namespace std; const int maxn=100010; int n,k,a[maxn],sum[maxn],dp[maxn]; signed main(){ scanf("%lld%lld",&n,&k); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); sum[i]=sum[i-1]+a[i]; } for(int i=1;i<=n+1;i++){ for(int j=max(1ll*0,i-k-1);j<i;j++){ dp[i]=max(dp[i],dp[j]+sum[i-1]-sum[j]); } } printf("%lld\n",dp[n+1]); return 0; } ```

by D0000 @ 2024-07-18 21:01:44


by xjybscpx @ 2024-07-29 22:36:33

这题暴力居然有90分?


|