标签:define 循环数组 display pre lap img AC out div
1 #include <iostream> 2 using namespace std; 3 #define ll long long 4 5 int main() 6 { 7 long long n; 8 cin>>n; 9 ll x; 10 long long sum=0; 11 long long sum1=0; 12 long long sum2=0; 13 long long maxn1=0; 14 long long maxn2=0; 15 for(long long i=1;i<=n;i++){ 16 cin>>x; 17 sum+=x; 18 sum1+=x; 19 x=-x; 20 sum2+=x; 21 if(sum1<=0) sum1=0; 22 maxn1=max(maxn1,sum1); 23 if(sum2<=0) sum2=0; 24 maxn2=max(maxn2,sum2); 25 } 26 cout<<max(maxn1,sum+maxn2)<<endl; 27 return 0; 28 }
标签:define 循环数组 display pre lap img AC out div
原文地址:https://www.cnblogs.com/fjqfjq/p/9026750.html