/ SB域 /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 28ms 432.0 KiB
#2 Accepted 4ms 904.0 KiB
#3 Wrong Answer 2ms 212.0 KiB
#4 Wrong Answer 3ms 340.0 KiB
#5 Wrong Answer 31ms 1.074 MiB
#6 Wrong Answer 27ms 1.84 MiB
#7 Wrong Answer 39ms 2.602 MiB
#8 Wrong Answer 51ms 3.363 MiB
#9 Wrong Answer 61ms 4.113 MiB
#10 Wrong Answer 61ms 4.117 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=1,a[500001];
struct node
{
	int num,len;
}q[500001];
int main()
{
	scanf("%d%d%d",&n,&st,&ed);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=st;i++)
	{
		while(r>l&&q[r].num>=a[i])r--;
		q[++r]=(node){a[i],i};
	}
	for(int i=st+1;i<=n;i++)
	{
		while(r>l&&q[r].num>=a[i])r--;
		q[++r]=(node){a[i],i};
		while(i-q[l].len>=ed)l++;
		if(i-q[l].len<st-1)continue;
		ans=max(sum[i]-q[l].num,ans);
	}
	printf("%d",ans);
	return 0;
}

信息

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