mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1800.cpp
This commit is contained in:
parent
e47513c310
commit
c6e14ad4d5
42
QUSTOJ/1800.cpp
Normal file
42
QUSTOJ/1800.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
#define NINF 0xc0c0c0c0
|
||||
inline int MaxSum(int n,int *a)
|
||||
{
|
||||
int sum=NINF,b=0;
|
||||
for(int i=0; i<n; i++)
|
||||
{
|
||||
if(b>0)
|
||||
{
|
||||
b+=a[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
b=a[i];
|
||||
}
|
||||
if(b>sum)
|
||||
{
|
||||
sum = b;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
#define MAXN 1024000
|
||||
int A[MAXN];
|
||||
int main()
|
||||
{
|
||||
int N;
|
||||
while(scanf("%d",&N)==1)
|
||||
{
|
||||
for(int i=0;i<N;i++)
|
||||
{
|
||||
scanf("%d",&A[i]);
|
||||
}
|
||||
int ans=MaxSum(N,A);
|
||||
printf("%d\n",ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user