Pagini recente » Cod sursa (job #3123785) | Cod sursa (job #1398376) | Cod sursa (job #2861274) | Cod sursa (job #2444368) | Cod sursa (job #1767835)
#include <cstdio>
#include <climits>
using namespace std;
int main () {
freopen ( "ssm.in", "r", stdin );
freopen ( "ssm.out", "w", stdout );
int n, i, x, my_max, my_min, sp, st, dr, poz_min;
scanf ( "%d", &n );
my_max = INT_MIN;
sp = my_min = poz_min = 0;
for ( i = 1 ; i <= n ; ++ i ) {
scanf ( "%d", &x );
sp += x;
if ( my_max < sp - my_min ) {
my_max = sp - my_min;
dr = i;
st = poz_min + 1;
}
if ( my_min > sp ) {
my_min = sp;
poz_min = i;
}
}
printf ( "%d %d %d", my_max, st, dr );
return 0;
}