Pagini recente » Cod sursa (job #215551) | Cod sursa (job #1109483) | Cod sursa (job #1423543) | Selectie echipe ACM ICPC, UPB 2008 | Cod sursa (job #1917305)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n,i,smax=-2000000000,s,poz,nr,x,nrmax;
int main()
{
fin>>n;
for(i=1;i<=n;i++)
{
fin>>x;
s+=x;
nr++;
if(s<0)
{
nr=0;
s=0;
}
else
if(s>smax)
poz=i,smax=s,nrmax=nr;
}
fout<<smax<<' '<<poz-nrmax+1<<' '<<poz;
fin.close();
fout.close();
return 0;
}