51Nod 1050 Loop Array Maximum sub-segment and portal
Emmmmm ... I thought it was an array copy for the maximum sub-segment and ... The amount of ... Not...... Think less of the feeling of reverse thinking ...
The maximal sub-segments of the loop array and the conversion into non-circular arrays can be of two kinds, one of the largest sub-segments of the non-cyclic array and (presumably, the kind of continuous, not spanning 1 and n types), and the other is the sum-.
#include <iostream>#include<algorithm>#include<string>#include<string.h>typedefLong Longll;using namespacestd;ll n,res,a[50005],b[50005],crt;ll dp,dpp,sum;intMain () { while(SCANF ("%lld", &n)! =EOF) {Sum=0; CRT =0; LL Minn=0x3f3f3f3f, maxx=-0x3f3f3f3f; for(inti =1; I <= N; i++) {scanf ("%lld", &A[i]); Sum+=A[i]; B[i]=A[i]; if(A[i] <0) crt++; } if(crt = = N) Break; for(inti =1; I <= N; i++) {DP+=A[i]; DPP+=B[i]; if(DP >Maxx) Maxx=DP; if(dpp<Minn) Minn=DPP; if(DP <0) DP=0; if(dpp>0) DPP=0; } printf ("%lld\n", Max (Sum-Minn,maxx)); } return 0;}
51Nod 1050 Loop Array Max sub-segment and DP