Pagini recente » Monitorul de evaluare | Cod sursa (job #1236719) | Cod sursa (job #1717440) | Cod sursa (job #1717364) | Cod sursa (job #307414)
Cod sursa(job #307414)
#include<fstream.h>
long long x,y,n,i,j,maxim,a[6000001],max;
int main()
{
ifstream f("ssm.in");
ofstream g("ssm.out");
f>>n;
for (i=1;i<=n;i++)
f>>a[i];
maxim=maxim-200000000;
for (i=1;i<=n;i++) {
max=0;
for (j=i;j<=n;j++)
{
max+=a[j];
if (max>maxim)
{maxim=max;
x=i;
y=j;
}
}
}
g<<maxim<<' '<<x<<' '<<y<<'\n';
g.close();
return 0;
}