Pagini recente » Cod sursa (job #164760) | Cod sursa (job #2772868) | Cod sursa (job #3157144) | Cod sursa (job #1296160) | Cod sursa (job #495730)
Cod sursa(job #495730)
#include<stdio.h>
struct vector{
int a, b, c;
};
vector best[6000001];
int main(){
freopen ("ssm.in", "r", stdin);
freopen ("ssm.out", "w", stdout);
int n, i, k;
scanf("%d ", &n);
for(i=1; i<=n; i++){
scanf("%d ", &k);
if(best[i-1].a+k>k){
best[i].a=best[i-1].a+k;
best[i].b=best[i-1].b;
}
else{
best[i].a=k;
best[i].b=i;
}
best[i].c=i;
}
int max=-999999, maxi, maxj;
for(i=1; i<=n; i++)
if(best[i].a>max){
max=best[i].a;
maxi=best[i].b;
maxj=best[i].c;
}
printf("%d %d %d\n", max, maxi, maxj);
return 0;
}