diff --git a/HDOJ/1231.cpp b/HDOJ/1231.cpp new file mode 100644 index 0000000..50d34ff --- /dev/null +++ b/HDOJ/1231.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +using namespace std; +#define MAXL 10240 +int a[MAXL]; +typedef struct +{ + int result,start,ends; +}PACK; +PACK MaxSum(int N) +{ + int sum=-1; + int tmp=0; + int start=0; + int ends=0; + int tmpstart=0; + int tmpends=0; + for(int i=0;i0) + { + tmp+=a[i]; + tmpends=i; + } + else + { + tmp=a[i]; + tmpstart=i; + } + if(tmp>sum) + { + sum=tmp; + start=tmpstart; + ends=tmpends; + } + } + if(ends=0) check=false; + } + if(check) + { + printf("0 %d %d\n",a[0],a[t-1]); + continue; + } + PACK c=MaxSum(t); + printf("%d %d %d\n",c.result,a[c.start],a[c.ends]); + } + return 0; +}