Submission #17977745


Source Code Expand

#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,a[N];
long long dp[N],mx[N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		dp[i]=dp[i-1]+a[i];
		mx[i]=max(mx[i-1],dp[i]);
	}

	long long x=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,x+mx[i]);
		x+=dp[i];
	}
	printf("%lld",ans);
}

Submission Info

Submission Time
Task D - Wandering
User dush1729
Language C++ (GCC 9.2.1)
Score 400
Code Size 369 Byte
Status AC
Exec Time 40 ms
Memory 7652 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
./Main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   14 |   scanf("%d",&a[i]);
      |   ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All around0_00.txt, around0_01.txt, around0_02.txt, around0_03.txt, around0_04.txt, around0_05.txt, extreme_00.txt, extreme_01.txt, handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
around0_00.txt AC 40 ms 7600 KiB
around0_01.txt AC 35 ms 7520 KiB
around0_02.txt AC 34 ms 7604 KiB
around0_03.txt AC 24 ms 5528 KiB
around0_04.txt AC 4 ms 3916 KiB
around0_05.txt AC 29 ms 6704 KiB
extreme_00.txt AC 36 ms 7572 KiB
extreme_01.txt AC 37 ms 7464 KiB
handmade_00.txt AC 4 ms 3708 KiB
handmade_01.txt AC 2 ms 3760 KiB
random_00.txt AC 36 ms 7568 KiB
random_01.txt AC 35 ms 7564 KiB
random_02.txt AC 36 ms 7488 KiB
random_03.txt AC 33 ms 7652 KiB
random_04.txt AC 5 ms 3916 KiB
random_05.txt AC 31 ms 6884 KiB
random_06.txt AC 4 ms 3976 KiB
random_07.txt AC 21 ms 6136 KiB
sample_01.txt AC 2 ms 3712 KiB
sample_02.txt AC 2 ms 3636 KiB
sample_03.txt AC 1 ms 3568 KiB