Pagini recente » Cod sursa (job #232122) | Cod sursa (job #1052248) | Cod sursa (job #2959462) | Cod sursa (job #1698598) | Cod sursa (job #406124)
Cod sursa(job #406124)
#include<fstream>
#include<stdio.h>
using namespace std;
/*ifstream f("ssm.in");
ofstream g("ssm.out"); */
int main ()
{
long long n,i,a[6000005],nr,best=-999999999,j,poz1,poz2,min,p_min;
freopen("suma.in","r",stdin);
freopen("suma.out","w",stdout);
scanf("%lld",&n);
a[0]=0;
for (i=1; i<=n; i++)
{
scanf("%lld",&nr);
a[i]=a[i-1]+nr;
}
min=99999999;
for (i=1; i<n; i++)
{
if (a[i]-min>best) { best=a[i]-min; poz1=p_min+1; poz2=i; }
if (a[i]<min) { min=a[i]; p_min=i; }
}
printf("%lld %lld %lld",best,poz1,poz2);
return 0;
}