Pagini recente » Arhiva de probleme | Rating Alexandra Beldica (alexandrab0507) | Rating Ionita Andrei Lucian (TheCreeep) | Diferente pentru arhiva intre reviziile 42 si 43 | Cod sursa (job #3293614)
#include <fstream>
#define int long long
using namespace std;
ifstream fcin("ssm.in");
ofstream fout("ssm.out");
int n,x,s,maxx=-(1LL<<40),st, ind1,ind2;
signed main()
{
fcin>>n;
st=1;
for(int i=1; i<=n; i++)
{
fcin>>x;
s+=x;
if(s>maxx)
{
maxx=s;
ind1=st;
ind2=i;
}
if(s<0) st=i+1, s=0;
}
fout<<maxx<<" "<<ind1<<" "<<ind2;
return 0;
}