首页 > 其他 > 详细

P5638 【CSGRound2】光骓者的荣耀

时间:2020-09-19 23:14:49      阅读:51      评论:0      收藏:0      [点我收藏+]

水题

  • 我们肯定向前传送
  • 求长为k的最大连续子段和,然后总长减去就行了
const int N=1e6+10;
LL a[N];
LL sum[N];
int n,k;

int main()
{
    cin>>n>>k;
    for(int i=1;i<=n-1;i++) cin>>a[i],sum[i]=sum[i-1]+a[i];

    LL res=0;
    for(int i=k;i<=n-1;i++)
        res=max(res,sum[i]-sum[i-k]);

    cout<<sum[n-1]-res<<endl;
    //system("pause");
}

P5638 【CSGRound2】光骓者的荣耀

原文:https://www.cnblogs.com/fxh0707/p/13697686.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!