/ SB域 /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Accepted 19ms 520.0 KiB
#2 Accepted 19ms 800.0 KiB
#3 Wrong Answer 1ms 316.0 KiB
#4 Wrong Answer 2ms 352.0 KiB
#5 Wrong Answer 14ms 728.0 KiB
#6 Wrong Answer 25ms 1.324 MiB
#7 Wrong Answer 37ms 1.566 MiB
#8 Wrong Answer 49ms 2.098 MiB
#9 Wrong Answer 64ms 2.637 MiB
#10 Accepted 62ms 3.996 MiB

代码

#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int st,ed,n,sum[500001],ans=-2147483647,l=1,r=0,q[500001],x;
int main()
{
	scanf("%d%d%d",&n,&st,&ed);
	for(int i=1;i<=n;i++)scanf("%d",&x),sum[i]=sum[i-1]+x;
	for(int i=st;i<=n;i++)
	{
		while(r>=l&&i-q[l]>ed)l++;
		while(r>=l&&sum[q[r]]>=sum[i])r--;
		q[++r]=i-st;
		ans=max(ans,sum[i]-sum[q[l]]);
	}
	printf("%d",ans);
	return 0;
}

信息

递交者
类型
递交
题目
【模板】最大子序和
题目数据
下载
语言
C++
递交时间
2019-10-01 08:44:36
评测时间
2019-10-01 08:44:36
评测机
分数
30
总耗时
298ms
峰值内存
3.996 MiB