Pagini recente » Cod sursa (job #1589233) | Cod sursa (job #781457) | Cod sursa (job #1789689) | Cod sursa (job #3162836) | Cod sursa (job #2473930)
#include <stdio.h>
#include <stdlib.h>
int main(){
int n,a,scmax,st,dr,i,sc,x;
FILE *fin,*fout;
fin=fopen("ssm.in","r");
fout=fopen("ssm.out","w");
fscanf(fin,"%d",&n);
x=1;
sc=smax=-1000000000;
for(i=0;i<n;i++){
fscanf(fin,"%d",&a);
if(sc<0){
s=0;
x=i+1;
}
sc+=a;
if(sc>scmax){
st=x;
dr=i+1;
scmax=sc;
}
}
fprintf(fout,"%d %d %d",scmax,st,dr);
fclose(fin);
fclose(fout);
return 0;
}