Pagini recente » Cod sursa (job #2324503) | Cod sursa (job #1069736) | Cod sursa (job #449914) | Cod sursa (job #1049950) | Cod sursa (job #1149009)
#include<limits.h>
#include<fstream>
using namespace std;
ifstream in ("ssm.in");
ofstream out ("ssm.out");
int v[6000001],n;
int main(){
int i,j,k,sc,smax=INT_MIN,start,end;
in>>n;
for(i=1;i<=n;i++)in>>v[i];
for(i=1;i<=n;i++)
for(j=i;j<=n;j++){
sc=0;
for(k=i;k<=j;k++)
sc+=v[k];
if(sc>smax){
smax=sc;
start=i;
end=j;
}
}
out<<smax<<" "<<start<<" "<<end;
return 0;
}