Cod sursa(job #491171)
| Utilizator | Data | 10 octombrie 2010 15:40:05 | |
|---|---|---|---|
| Problema | Subsecventa de suma maxima | Scor | 65 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include<stdio.h>
FILE *f=fopen("ssm.in","r");
FILE *g=fopen("ssm.out", "w");
int n, Si, Vi, Sii, max , pmax, umax, u ,p,i,Vii;
int main(){
fscanf(f, "%d %d", &n, &Si);
Vi=Si;
p=u=1;
for (i=2;i<=n;i++){
fscanf (f,"%d", & Sii);
if (Sii<Si+Sii){
Vii=Si+Sii;
++u;
}
else {
Vii=Sii;
p=u=i;
}
Si=Vii;
if (Vii>max){
max=Vii, pmax=p, umax=u;
}
}
fprintf(g, "%d %d %d", max, pmax, umax);
fclose(f);
fclose(g);
return 0;
}
