Pagini recente » Statisticile problemei Mediana | Rating Docea Andrei (Koniac) | Profil PhilipDumitru | Rating Boca Nelu Cristian (bocacristi) | Cod sursa (job #3293612)
#include <fstream>
#define int long long
using namespace std;
ifstream fcin("ssm.in");
ofstream fout("ssm.out");
int n,v[100001],s,maxx,st, ind1,ind2;
signed main()
{
fcin>>n;
for(int i=1; i<=n; i++)
fcin>>v[i];
st=1;
for(int i=1; i<=n; i++)
{
s+=v[i];
if(s>maxx)
{
maxx=s;
ind1=st;
ind2=i;
}
if(s<0) st=i+1, s=0;
}
fout<<maxx<<" "<<ind1<<" "<<ind2;
return 0;
}