Pagini recente » Cod sursa (job #1661090) | Cod sursa (job #302017) | Cod sursa (job #1324060) | Cod sursa (job #2122431) | Cod sursa (job #763598)
Cod sursa(job #763598)
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int main(){
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
scanf("%d",&n);
int p,u,bst,p1,bst1,x;
scanf("%d",&bst);
p = u = p1 = 1; bst1 = bst;
for(int i=2;i<=n;i++)
{
scanf("%d",&x);
if(x > bst1 + x)
{
bst1 = x;
p1 = i;
} else bst1 += x;
if(bst1 > bst)
{
bst = bst1;
p = p1;
u = i;
}
}
printf("%d %d %d\n",bst,p,u);
return 0;
}