Pagini recente » Diferente pentru home intre reviziile 391 si 903 | Diferente pentru home intre reviziile 367 si 903 | Cod sursa (job #2970151) | Rating Moga Karina (karinamoga) | Cod sursa (job #2333038)
#include <stdio.h>
#include <math.h>
int main(){
freopen("ssm.in", "r", stdin);
freopen("ssm.out", "w", stdout);
int s, maxim, n, i, a, smax, i1, i2, j1;
s = 0;
maxim = smax = - INFINITY;
scanf("%d", &n);
i1 = 1;
for (i = 1; i <= n; i++)
{
scanf("%d", &a);
if (maxim < a)
{
j1 = i;
maxim = a;
}
s = s + a;
if (smax < s)
{
i2 = i;
smax = s;
}
if (s < 0)
{
s = 0;
i1 = i + 1;
}
}
if (maxim < 0)
printf("%d %d %d", maxim, j1, j1);
else
printf("%d %d %d", smax, i1, i2);
return 0;
}